cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 3/9] gfs2: Use gfs2 wrapper to sync inode before calling generic_file_splice_read()
Date: Fri, 20 May 2016 11:22:21 -0500	[thread overview]
Message-ID: <1463761347-19864-4-git-send-email-rpeterso@redhat.com> (raw)
In-Reply-To: <1463761347-19864-1-git-send-email-rpeterso@redhat.com>

From: Abhi Das <adas@redhat.com>

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 <adas@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
 fs/gfs2/file.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index c9384f9..fd9a10e 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,
-- 
2.5.5



  parent reply	other threads:[~2016-05-20 16:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20 16:22 [Cluster-devel] [PATCH 0/9] GFS2: Pre-pull patch posting (merge window) Bob Peterson
2016-05-20 16:22 ` [Cluster-devel] [PATCH 1/9] GFS2: ignore unlock failures after withdraw Bob Peterson
2016-05-20 16:22 ` [Cluster-devel] [PATCH 2/9] GFS2: Get rid of dead code in inode_go_demote_ok Bob Peterson
2016-05-20 16:22 ` Bob Peterson [this message]
2016-05-20 16:22 ` [Cluster-devel] [PATCH 4/9] GFS2: fs/gfs2/glock.c: Deinline do_error, save 1856 bytes Bob Peterson
2016-05-20 16:22 ` [Cluster-devel] [PATCH 5/9] GFS2: Don't dereference inode in gfs2_inode_lookup until it's valid Bob Peterson
2016-05-20 16:22 ` [Cluster-devel] [PATCH 6/9] GFS2: Add calls to gfs2_holder_uninit in two error handlers Bob Peterson
2016-05-20 16:22 ` [Cluster-devel] [PATCH 7/9] gfs2: use inode_lock/unlock instead of accessing i_mutex directly Bob Peterson
2016-05-20 16:22 ` [Cluster-devel] [PATCH 8/9] GFS2: Remove allocation parms from gfs2_rbm_find Bob Peterson
2016-05-20 16:22 ` [Cluster-devel] [PATCH 9/9] GFS2: Refactor gfs2_remove_from_journal Bob Peterson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463761347-19864-4-git-send-email-rpeterso@redhat.com \
    --to=rpeterso@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).