mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
default to simple_setattr
With the new truncate sequence every filesystem that wants to support file size changes on disk needs to implement its own ->setattr. So instead of calling inode_setattr which supports size changes call into a simple method that doesn't support this. simple_setattr is almost what we want except that it does not mark the inode dirty after changes. Given that marking the inode dirty is a no-op for the simple in-memory filesystems that use simple_setattr currently just add the mark_inode_dirty call. Also add a WARN_ON for the presence of a truncate method to simple_setattr to catch new instances of it during the transition period. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
committed by
Al Viro
parent
6a1a90ad1b
commit
eef2380c18
@@ -237,13 +237,10 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
|
|||||||
if (ia_valid & ATTR_SIZE)
|
if (ia_valid & ATTR_SIZE)
|
||||||
down_write(&dentry->d_inode->i_alloc_sem);
|
down_write(&dentry->d_inode->i_alloc_sem);
|
||||||
|
|
||||||
if (inode->i_op && inode->i_op->setattr) {
|
if (inode->i_op->setattr)
|
||||||
error = inode->i_op->setattr(dentry, attr);
|
error = inode->i_op->setattr(dentry, attr);
|
||||||
} else {
|
else
|
||||||
error = inode_change_ok(inode, attr);
|
error = simple_setattr(dentry, attr);
|
||||||
if (!error)
|
|
||||||
error = inode_setattr(inode, attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ia_valid & ATTR_SIZE)
|
if (ia_valid & ATTR_SIZE)
|
||||||
up_write(&dentry->d_inode->i_alloc_sem);
|
up_write(&dentry->d_inode->i_alloc_sem);
|
||||||
|
16
fs/libfs.c
16
fs/libfs.c
@@ -370,21 +370,26 @@ int simple_setsize(struct inode *inode, loff_t newsize)
|
|||||||
EXPORT_SYMBOL(simple_setsize);
|
EXPORT_SYMBOL(simple_setsize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* simple_setattr - setattr for simple in-memory filesystem
|
* simple_setattr - setattr for simple filesystem
|
||||||
* @dentry: dentry
|
* @dentry: dentry
|
||||||
* @iattr: iattr structure
|
* @iattr: iattr structure
|
||||||
*
|
*
|
||||||
* Returns 0 on success, -error on failure.
|
* Returns 0 on success, -error on failure.
|
||||||
*
|
*
|
||||||
* simple_setattr implements setattr for an in-memory filesystem which
|
* simple_setattr is a simple ->setattr implementation without a proper
|
||||||
* does not store its own file data or metadata (eg. uses the page cache
|
* implementation of size changes.
|
||||||
* and inode cache as its data store).
|
*
|
||||||
|
* It can either be used for in-memory filesystems or special files
|
||||||
|
* on simple regular filesystems. Anything that needs to change on-disk
|
||||||
|
* or wire state on size changes needs its own setattr method.
|
||||||
*/
|
*/
|
||||||
int simple_setattr(struct dentry *dentry, struct iattr *iattr)
|
int simple_setattr(struct dentry *dentry, struct iattr *iattr)
|
||||||
{
|
{
|
||||||
struct inode *inode = dentry->d_inode;
|
struct inode *inode = dentry->d_inode;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
WARN_ON_ONCE(inode->i_op->truncate);
|
||||||
|
|
||||||
error = inode_change_ok(inode, iattr);
|
error = inode_change_ok(inode, iattr);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
@@ -396,7 +401,8 @@ int simple_setattr(struct dentry *dentry, struct iattr *iattr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
setattr_copy(inode, iattr);
|
setattr_copy(inode, iattr);
|
||||||
return error;
|
mark_inode_dirty(inode);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(simple_setattr);
|
EXPORT_SYMBOL(simple_setattr);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user