aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/file.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2011-08-23 05:19:25 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2011-10-21 07:39:29 -0400
commit9453615a1a7ef3fa910c6464a619595556cfcd63 (patch)
tree40242c84367376197420ce12e50ae29e720dc5e3 /fs/gfs2/file.c
parent9a63edd12ba3c18351f00d6b77a6b2f49f2b8eb6 (diff)
GFS2: Fix lseek after SEEK_DATA, SEEK_HOLE have been added
We need to take the inode's glock whenever the inode's size is referenced, otherwise it might not be uptodate. Even though generic_file_llseek_unlocked() doesn't implement SEEK_DATA, SEEK_HOLE directly, it does reference the inode's size in those cases, so we need to add them to the list of origins which need the glock. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> Cc: Andi Kleen <ak@linux.intel.com>
Diffstat (limited to 'fs/gfs2/file.c')
-rw-r--r--fs/gfs2/file.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 4416a1cfa1fe..d717b72500a4 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -59,15 +59,24 @@ static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin)
59 struct gfs2_holder i_gh; 59 struct gfs2_holder i_gh;
60 loff_t error; 60 loff_t error;
61 61
62 if (origin == 2) { 62 switch (origin) {
63 case SEEK_END: /* These reference inode->i_size */
64 case SEEK_DATA:
65 case SEEK_HOLE:
63 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, 66 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
64 &i_gh); 67 &i_gh);
65 if (!error) { 68 if (!error) {
66 error = generic_file_llseek_unlocked(file, offset, origin); 69 error = generic_file_llseek_unlocked(file, offset, origin);
67 gfs2_glock_dq_uninit(&i_gh); 70 gfs2_glock_dq_uninit(&i_gh);
68 } 71 }
69 } else 72 break;
73 case SEEK_CUR:
74 case SEEK_SET:
70 error = generic_file_llseek_unlocked(file, offset, origin); 75 error = generic_file_llseek_unlocked(file, offset, origin);
76 break;
77 default:
78 error = -EINVAL;
79 }
71 80
72 return error; 81 return error;
73} 82}