[PATCH] ocfs2: llseek need to inode cluster lock and unlock for update the inode size in SEEK_END.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux