* [Cluster-devel] GFS2: Fix lseek after SEEK_DATA, SEEK_HOLE have been added
@ 2011-08-23 9:09 Steven Whitehouse
0 siblings, 0 replies; only message in thread
From: Steven Whitehouse @ 2011-08-23 9:09 UTC (permalink / raw)
To: cluster-devel.redhat.com
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.
[Andi - I just spotted your lseek patches and since this ought
to be pushed into the tree as a bug fix, I'm assuming that you'll
rebase on top of this. I assume that you are aiming for the
next merge window with your patches, but let me know if thats a
problem]
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 4416a1c..d717b72 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)
struct gfs2_holder i_gh;
loff_t error;
- if (origin == 2) {
+ switch (origin) {
+ case SEEK_END: /* These reference inode->i_size */
+ case SEEK_DATA:
+ case SEEK_HOLE:
error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
&i_gh);
if (!error) {
error = generic_file_llseek_unlocked(file, offset, origin);
gfs2_glock_dq_uninit(&i_gh);
}
- } else
+ break;
+ case SEEK_CUR:
+ case SEEK_SET:
error = generic_file_llseek_unlocked(file, offset, origin);
+ break;
+ default:
+ error = -EINVAL;
+ }
return error;
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-08-23 9:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-23 9:09 [Cluster-devel] GFS2: Fix lseek after SEEK_DATA, SEEK_HOLE have been added Steven Whitehouse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).