Re: [rfc][patch 3/4] fs: new truncate sequence

Christoph Hellwig
2009-07-08T10:47:15Z

On Wed, Jul 08, 2009 at 08:32:25AM +0200, Nick Piggin wrote:
> Thanks for the patch, I think I will fold it in to the series. I
> think we probably do need to call simple_setsize in inode_setattr
> though (unless you propose to eventually convert every filesystem
> to define a .setattr). This would also require eg. your ext2
> conversion to strip ATTR_SIZE before passing through to inode_setattr.

Yes, we should eventually make .setattr mandatory. Doing a default
action when a method lacks tends to cause more issues than it solves.

I'm happy to help in doing that part of the conversion (and also other
bits)

> > int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
> > {
> > struct inode *inode = dentry->d_inode;
> > int error;
> >
> > + if (iattr->ia_valid & ATTR_SIZE) {
> > + error = ext2_setsize(inode, iattr->ia_size);
> > + if (error)
> > + return error;
> > + }
> > +
> > error = inode_change_ok(inode, iattr);
> > if (error)
> > return error;
>
> Probably want to call inode_change_ok first here.

Right now I tried to no reorder anything versus the previous patch.

But yes, we should do all the checks first. Possibly we can even add
a call to inode_newsize_ok to inode_change_ok, but I'd like to defer
that until all conversions are done and we can easily audit it.