All of lore.kernel.org
 help / color / mirror / Atom feed
From: shencanquan <shencanquan@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Mark Fasheh <mfasheh@suse.com>
Cc: <linux-fsdevel@vger.kernel.org>,
	"ocfs2-devel@oss.oracle.com" <ocfs2-devel@oss.oracle.com>
Subject: [PATCH] ocfs2: llseek need to inode cluster lock and unlock for update the inode size in SEEK_END.
Date: Mon, 17 Jun 2013 22:48:54 +0800	[thread overview]
Message-ID: <51BF21D6.9080008@huawei.com> (raw)

We found that llseek has a bug when in SEEK_END.  it need to add the 
inode lock and unlock.
This bug can be reproduce the following scenario:
On one nodeA, open the file and then write some data to file and close 
the file .
On another nodeB , open the file and llseek the end of file . the 
position of file is old.

Signed-off-by: jensen <shencanquan@huawei.com>
---
  file.c |    7 +++++++
  1 file changed, 7 insertions(+)

diff --git a/file.c b/file.c
index ff54014..4ee7c80 100644
--- a/file.c
+++ b/file.c
@@ -2626,6 +2626,13 @@ static loff_t ocfs2_file_llseek(struct file 
*file, loff_t offset, int whence)
      case SEEK_SET:
          break;
      case SEEK_END:
+        /*need to inode lock and unlock for update the inode size.*/
+        ret = ocfs2_inode_lock(inode, NULL, 0);
+        if (ret < 0) {
+            mlog_errno(ret);
+            goto out;
+        }
+        ocfs2_inode_unlock(inode, 0);
          offset += inode->i_size;
          break;
      case SEEK_CUR:
-- 
1.7.9.7


WARNING: multiple messages have this Message-ID (diff)
From: shencanquan <shencanquan@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Mark Fasheh <mfasheh@suse.com>
Cc: linux-fsdevel@vger.kernel.org,
	"ocfs2-devel@oss.oracle.com" <ocfs2-devel@oss.oracle.com>
Subject: [Ocfs2-devel] [PATCH] ocfs2: llseek need to inode cluster lock and unlock for update the inode size in SEEK_END.
Date: Mon, 17 Jun 2013 22:48:54 +0800	[thread overview]
Message-ID: <51BF21D6.9080008@huawei.com> (raw)

We found that llseek has a bug when in SEEK_END.  it need to add the 
inode lock and unlock.
This bug can be reproduce the following scenario:
On one nodeA, open the file and then write some data to file and close 
the file .
On another nodeB , open the file and llseek the end of file . the 
position of file is old.

Signed-off-by: jensen <shencanquan@huawei.com>
---
  file.c |    7 +++++++
  1 file changed, 7 insertions(+)

diff --git a/file.c b/file.c
index ff54014..4ee7c80 100644
--- a/file.c
+++ b/file.c
@@ -2626,6 +2626,13 @@ static loff_t ocfs2_file_llseek(struct file 
*file, loff_t offset, int whence)
      case SEEK_SET:
          break;
      case SEEK_END:
+        /*need to inode lock and unlock for update the inode size.*/
+        ret = ocfs2_inode_lock(inode, NULL, 0);
+        if (ret < 0) {
+            mlog_errno(ret);
+            goto out;
+        }
+        ocfs2_inode_unlock(inode, 0);
          offset += inode->i_size;
          break;
      case SEEK_CUR:
-- 
1.7.9.7

             reply	other threads:[~2013-06-17 14:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-17 14:48 shencanquan [this message]
2013-06-17 14:48 ` [Ocfs2-devel] [PATCH] ocfs2: llseek need to inode cluster lock and unlock for update the inode size in SEEK_END shencanquan
2013-06-17 15:17 ` Jeff Liu
2013-06-17 15:17   ` [Ocfs2-devel] " Jeff Liu
2013-06-17 17:02   ` Mark Fasheh
2013-06-17 17:02     ` Mark Fasheh
2013-06-18  1:03     ` shencanquan
2013-06-18  0:57   ` shencanquan

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=51BF21D6.9080008@huawei.com \
    --to=shencanquan@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mfasheh@suse.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.