All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Piggin <npiggin@suse.de>
To: Tao Ma <tao.ma@oracle.com>
Cc: ocfs2-devel@oss.oracle.com, joel.becker@oracle.com,
	linux-fsdevel@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Subject: [Ocfs2-devel] [PATCH] ocfs2: Remove the deprecated inode_setattr.
Date: Wed, 09 Jun 2010 09:16:11 -0000	[thread overview]
Message-ID: <20100609091604.GX26335@laptop> (raw)
In-Reply-To: <1276073300-7360-1-git-send-email-tao.ma@oracle.com>

On Wed, Jun 09, 2010 at 04:48:20PM +0800, Tao Ma wrote:
> Nick has changed the turncate sequence and now inode_setattr
> is deprecated. ocfs2 has done the most work of i_size change
> before calling inode_setattr, so we are safe to just call
> simple_setsize to update the i_size in vfs inode and then
> generic_setattr.
> 
> As for dlmfs, we don't allow inode size change, so it is safe
> for us to just call generic_setattr.
> 
> Cc: Nick Piggin <npiggin@suse.de>
> Signed-off-by: Tao Ma <tao.ma@oracle.com>
> ---
>  fs/ocfs2/dlmfs/dlmfs.c |    2 +-
>  fs/ocfs2/file.c        |   18 +++++++++---------
>  2 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
> index b83d610..e959b88 100644
> --- a/fs/ocfs2/dlmfs/dlmfs.c
> +++ b/fs/ocfs2/dlmfs/dlmfs.c
> @@ -215,7 +215,7 @@ static int dlmfs_file_setattr(struct dentry *dentry, struct iattr *attr)
>  	attr->ia_valid &= ~ATTR_SIZE;
>  	error = inode_change_ok(inode, attr);
>  	if (!error)
> -		error = inode_setattr(inode, attr);
> +		generic_setattr(inode, attr);

This brings up my question again about simply _ignoring_ ATTR_SIZE changes.
One problem is that truncate calls which send down ATTR_SIZE might also
be sending down ATTR_MODE or ATTR_?TIME which should not be applied if
the ATTR_SIZE fails, one would think.

The other thing is that shouldn't we return -EINVAL or somesuch rather
than silently ignoring?

Anyway, several other pseudo filesystems do other stuff like tihs so
it's not something to bother with in this patch.


>  
>  	return error;
>  }
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index 6a13ea6..06fd85c 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -1052,17 +1052,17 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
>  	}
>  
>  	/*
> -	 * This will intentionally not wind up calling simple_setsize(),
> -	 * since all the work for a size change has been done above.
> -	 * Otherwise, we could get into problems with truncate as
> -	 * ip_alloc_sem is used there to protect against i_size
> -	 * changes.
> +	 * Since all the work for a size change has been done above,
> +	 * we only need to call simple_setsize to update i_size.
>  	 */
> -	status = inode_setattr(inode, attr);
> -	if (status < 0) {
> -		mlog_errno(status);
> -		goto bail_commit;
> +	if (attr->ia_valid & ATTR_SIZE) {
> +		status = simple_setsize(inode, attr->ia_size);
> +		if (status < 0) {
> +			mlog_errno(status);
> +			goto bail_commit;
> +		}
>  	}
> +	generic_setattr(inode, attr);
>  
>  	status = ocfs2_mark_inode_dirty(handle, inode, bh);
>  	if (status < 0)

simple_setsize of course calls inode_newsize_ok, which may fail. If
you're committing your on-disk truncates@this point, you will
prefer to hoist that check as early as possible so you cannot fail
here.

Just open code the truncate part of simple_setsize for now.

WARNING: multiple messages have this Message-ID (diff)
From: Nick Piggin <npiggin@suse.de>
To: Tao Ma <tao.ma@oracle.com>
Cc: ocfs2-devel@oss.oracle.com, joel.becker@oracle.com,
	linux-fsdevel@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] ocfs2: Remove the deprecated inode_setattr.
Date: Wed, 9 Jun 2010 19:16:04 +1000	[thread overview]
Message-ID: <20100609091604.GX26335@laptop> (raw)
In-Reply-To: <1276073300-7360-1-git-send-email-tao.ma@oracle.com>

On Wed, Jun 09, 2010 at 04:48:20PM +0800, Tao Ma wrote:
> Nick has changed the turncate sequence and now inode_setattr
> is deprecated. ocfs2 has done the most work of i_size change
> before calling inode_setattr, so we are safe to just call
> simple_setsize to update the i_size in vfs inode and then
> generic_setattr.
> 
> As for dlmfs, we don't allow inode size change, so it is safe
> for us to just call generic_setattr.
> 
> Cc: Nick Piggin <npiggin@suse.de>
> Signed-off-by: Tao Ma <tao.ma@oracle.com>
> ---
>  fs/ocfs2/dlmfs/dlmfs.c |    2 +-
>  fs/ocfs2/file.c        |   18 +++++++++---------
>  2 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
> index b83d610..e959b88 100644
> --- a/fs/ocfs2/dlmfs/dlmfs.c
> +++ b/fs/ocfs2/dlmfs/dlmfs.c
> @@ -215,7 +215,7 @@ static int dlmfs_file_setattr(struct dentry *dentry, struct iattr *attr)
>  	attr->ia_valid &= ~ATTR_SIZE;
>  	error = inode_change_ok(inode, attr);
>  	if (!error)
> -		error = inode_setattr(inode, attr);
> +		generic_setattr(inode, attr);

This brings up my question again about simply _ignoring_ ATTR_SIZE changes.
One problem is that truncate calls which send down ATTR_SIZE might also
be sending down ATTR_MODE or ATTR_?TIME which should not be applied if
the ATTR_SIZE fails, one would think.

The other thing is that shouldn't we return -EINVAL or somesuch rather
than silently ignoring?

Anyway, several other pseudo filesystems do other stuff like tihs so
it's not something to bother with in this patch.


>  
>  	return error;
>  }
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index 6a13ea6..06fd85c 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -1052,17 +1052,17 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
>  	}
>  
>  	/*
> -	 * This will intentionally not wind up calling simple_setsize(),
> -	 * since all the work for a size change has been done above.
> -	 * Otherwise, we could get into problems with truncate as
> -	 * ip_alloc_sem is used there to protect against i_size
> -	 * changes.
> +	 * Since all the work for a size change has been done above,
> +	 * we only need to call simple_setsize to update i_size.
>  	 */
> -	status = inode_setattr(inode, attr);
> -	if (status < 0) {
> -		mlog_errno(status);
> -		goto bail_commit;
> +	if (attr->ia_valid & ATTR_SIZE) {
> +		status = simple_setsize(inode, attr->ia_size);
> +		if (status < 0) {
> +			mlog_errno(status);
> +			goto bail_commit;
> +		}
>  	}
> +	generic_setattr(inode, attr);
>  
>  	status = ocfs2_mark_inode_dirty(handle, inode, bh);
>  	if (status < 0)

simple_setsize of course calls inode_newsize_ok, which may fail. If
you're committing your on-disk truncates at this point, you will
prefer to hoist that check as early as possible so you cannot fail
here.

Just open code the truncate part of simple_setsize for now.


  reply	other threads:[~2010-06-09  9:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-09  8:48 [Ocfs2-devel] [PATCH] ocfs2: Remove the deprecated inode_setattr Tao Ma
2010-06-09  9:16 ` Nick Piggin [this message]
2010-06-09  9:16   ` Nick Piggin
2010-06-09  9:29   ` Tao Ma
2010-06-09  9:29     ` Tao Ma
2010-06-09  9:38     ` Nick Piggin
2010-06-09  9:38       ` [Ocfs2-devel] " Nick Piggin
2010-06-09 10:12       ` Joel Becker
2010-06-09 10:12         ` Joel Becker
2010-06-09 10:14         ` [Ocfs2-devel] " Christoph Hellwig
2010-06-09 10:14           ` Christoph Hellwig
2010-06-09 19:53           ` [Ocfs2-devel] " Joel Becker
2010-06-09 19:53             ` Joel Becker
2010-06-09 10:01   ` Christoph Hellwig
2010-06-09 10:01     ` Christoph Hellwig
2010-06-09 13:43     ` [Ocfs2-devel] " Tao Ma
2010-06-09 13:43       ` Tao Ma
2010-06-09 10:08 ` [Ocfs2-devel] " Joel Becker
2010-06-09 10:43   ` Nick Piggin
2010-06-09 10:43     ` [Ocfs2-devel] " Nick Piggin
2010-06-09 13:54   ` Tao Ma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100609091604.GX26335@laptop \
    --to=npiggin@suse.de \
    --cc=hch@lst.de \
    --cc=joel.becker@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=tao.ma@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.