All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH v2] ocfs2: llseek need to require ocfs2 inode lock for updating the size in SEEK_END
@ 2013-06-19 10:38 shencanquan
  2013-06-19 13:12 ` Jeff Liu
  0 siblings, 1 reply; 2+ messages in thread
From: shencanquan @ 2013-06-19 10:38 UTC (permalink / raw)
  To: ocfs2-devel

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.

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.
+		*/
+		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) {
-- 
1.7.9.7

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-19 13:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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.