From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Whitehouse Date: Thu, 8 Sep 2011 16:50:18 +0100 Subject: [Cluster-devel] [PATCH 09/19] GFS2: Fix lseek after SEEK_DATA, SEEK_HOLE have been added In-Reply-To: <1315497028-8473-1-git-send-email-swhiteho@redhat.com> References: <1315497028-8473-1-git-send-email-swhiteho@redhat.com> Message-ID: <1315497028-8473-10-git-send-email-swhiteho@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 Cc: Andi Kleen 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; } -- 1.7.4