All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Liu <jeff.liu@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH v2] ocfs2: llseek need to require ocfs2 inode lock for updating the size in SEEK_END
Date: Wed, 19 Jun 2013 21:12:59 +0800	[thread overview]
Message-ID: <51C1AE5B.9090402@oracle.com> (raw)
In-Reply-To: <51C18A31.40008@huawei.com>

Hi Canquan,

On 06/19/2013 06:38 PM, shencanquan wrote:

> The test scenario is following:
> 
> There are two node, one is nodeA, another is nodeB
> On nodeA, the test program open the file and write some data to the
> file and then close the file.
> On nodeB, the another test program open the file and llseek the end of
> file. we found that the position of file is old.
> 
> After apply this patch. it is ok on nodeB. the position of file is
> update to date.

But I still not get a direct viewing.  That is to say the currently
incorrect behavior as well as the correct result with this fix up.
This would be useful not only for the patch reviewer but also can be
proved that your fix is really works as expected.

That is not hard to wrap up the test code and results into the patch
commit log, e.g,

On nodeA:
---------
1) Record the test file size
2) Append the test file && close it

On nodeB:
---------
1) Open/seek to the end of the test file and record/verify the result.

You can write the test code in any language that you preferred. e.g, use
python to verify the SEEK_END result with this patch:

$ python -c "import os;f=open('test_file_path_name', 'r');f.seek(0, 2); \
             fsize=f.tell();print fsize"

> 
> Signed-off-by: jensen <shencanquan@huawei.com>
> ---
>  fs/ocfs2/file.c |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index ff54014..f2570ba 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -2626,7 +2626,16 @@ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence)
>  	case SEEK_SET:
>  		break;
>  	case SEEK_END:
> +		/* SEEK_END requires the OCFS2 inode lock because
> +		 * it uses the inode size.

The comments is wrong.  In general, the inode size means that how
many bytes is used to store an inode in file system blocks.

I'd like to suggest the comments below:
		/* SEEK_END requires the OCFS2 inode lock for the
		 * file because it references the file's size.
		 */

Hi Mark, what's your opinion?

> +		*/

		^^ <-- No alignment to above lines.

> +		ret = ocfs2_inode_lock(inode, NULL, 0);
> +		if (ret < 0) {
> +			mlog_errno(ret);
> +			goto out;
> +		}
>  		offset += inode->i_size;
> +		ocfs2_inode_unlock(inode, 0);
>  		break;
>  	case SEEK_CUR:
>  		if (offset == 0) {


Thanks,
-Jeff

      reply	other threads:[~2013-06-19 13:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-19 10:38 [Ocfs2-devel] [PATCH v2] ocfs2: llseek need to require ocfs2 inode lock for updating the size in SEEK_END shencanquan
2013-06-19 13:12 ` Jeff Liu [this message]

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=51C1AE5B.9090402@oracle.com \
    --to=jeff.liu@oracle.com \
    --cc=ocfs2-devel@oss.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.