From 611526756a3d0fa7f4d1c519397ba8898f40443f Mon Sep 17 00:00:00 2001 From: Abhi Das Date: Tue, 5 Apr 2016 12:06:15 -0400 Subject: gfs2: Use gfs2 wrapper to sync inode before calling generic_file_splice_read() gfs2_file_splice_read() f_op grabs and releases the cluster-wide inode glock to sync the inode size to the latest. Without this, generic_file_splice_read() uses an older i_size value and can return EOF for valid offsets in the inode. Signed-off-by: Abhi Das Signed-off-by: Bob Peterson --- fs/gfs2/file.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'fs/gfs2/file.c') diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index c9384f932975..fd9a10e4518d 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -950,6 +950,30 @@ out_uninit: return ret; } +static ssize_t gfs2_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, size_t len, + unsigned int flags) +{ + struct inode *inode = in->f_mapping->host; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_holder gh; + int ret; + + mutex_lock(&inode->i_mutex); + + ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh); + if (ret) { + mutex_unlock(&inode->i_mutex); + return ret; + } + + gfs2_glock_dq_uninit(&gh); + mutex_unlock(&inode->i_mutex); + + return generic_file_splice_read(in, ppos, pipe, len, flags); +} + + static ssize_t gfs2_file_splice_write(struct pipe_inode_info *pipe, struct file *out, loff_t *ppos, size_t len, unsigned int flags) @@ -1112,7 +1136,7 @@ const struct file_operations gfs2_file_fops = { .fsync = gfs2_fsync, .lock = gfs2_lock, .flock = gfs2_flock, - .splice_read = generic_file_splice_read, + .splice_read = gfs2_file_splice_read, .splice_write = gfs2_file_splice_write, .setlease = simple_nosetlease, .fallocate = gfs2_fallocate, @@ -1140,7 +1164,7 @@ const struct file_operations gfs2_file_fops_nolock = { .open = gfs2_open, .release = gfs2_release, .fsync = gfs2_fsync, - .splice_read = generic_file_splice_read, + .splice_read = gfs2_file_splice_read, .splice_write = gfs2_file_splice_write, .setlease = generic_setlease, .fallocate = gfs2_fallocate, -- cgit From 9c7fe83530a351845719acf1dda0587e8c743588 Mon Sep 17 00:00:00 2001 From: Daniel DeFreez Date: Tue, 19 Apr 2016 19:57:45 -0400 Subject: GFS2: Add calls to gfs2_holder_uninit in two error handlers This patch fixes two locations that do not call gfs2_holder_uninit if gfs2_glock_nq returns an error. Signed-off-by: Daniel DeFreez Signed-off-by: Bob Peterson --- fs/gfs2/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'fs/gfs2/file.c') diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index fd9a10e4518d..f33fd92e5f49 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -160,7 +160,7 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr) gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &gh); error = gfs2_glock_nq(&gh); if (error) - return error; + goto out_uninit; fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_diskflags); if (!S_ISDIR(inode->i_mode) && ip->i_diskflags & GFS2_DIF_JDATA) @@ -169,6 +169,7 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr) error = -EFAULT; gfs2_glock_dq(&gh); +out_uninit: gfs2_holder_uninit(&gh); return error; } -- cgit From 80f4781d2c0ba63bf9ab4de90a6829a1368b80a3 Mon Sep 17 00:00:00 2001 From: Abhi Das Date: Mon, 2 May 2016 07:07:01 -0500 Subject: gfs2: use inode_lock/unlock instead of accessing i_mutex directly i_mutex has been replaced by i_rwsem and directly accessing the non-existent i_mutex breaks the kernel build. Signed-off-by: Abhi Das Signed-off-by: Bob Peterson --- fs/gfs2/file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fs/gfs2/file.c') diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index f33fd92e5f49..374dd5327101 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -960,16 +960,16 @@ static ssize_t gfs2_file_splice_read(struct file *in, loff_t *ppos, struct gfs2_holder gh; int ret; - mutex_lock(&inode->i_mutex); + inode_lock(inode); ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh); if (ret) { - mutex_unlock(&inode->i_mutex); + inode_unlock(inode); return ret; } gfs2_glock_dq_uninit(&gh); - mutex_unlock(&inode->i_mutex); + inode_unlock(inode); return generic_file_splice_read(in, ppos, pipe, len, flags); } -- cgit