All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 3/9] pnfs: add return_range method
Date: Tue,  9 Sep 2014 09:40:47 -0700	[thread overview]
Message-ID: <1410280853-3964-4-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1410280853-3964-1-git-send-email-hch@lst.de>

If a layout driver keeps per-inode state outside of the layout segments it
needs to be notified of any layout returns or recalls on an inode, and not
just about the freeing of layout segments.  Add a method to acomplish this,
which will allow the block layout driver to handle the case of truncated
and re-expanded files properly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/nfs/callback_proc.c | 12 +++++++++---
 fs/nfs/pnfs.c          | 10 ++++++++++
 fs/nfs/pnfs.h          |  3 +++
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 35f2712..226e206 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -181,10 +181,16 @@ static u32 initiate_file_draining(struct nfs_client *clp,
 	spin_lock(&ino->i_lock);
 	if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags) ||
 	    pnfs_mark_matching_lsegs_invalid(lo, &free_me_list,
-					&args->cbl_range))
+					&args->cbl_range)) {
 		rv = NFS4ERR_DELAY;
-	else
-		rv = NFS4ERR_NOMATCHING_LAYOUT;
+		goto unlock;
+	}
+
+	if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
+		NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo,
+			&args->cbl_range);
+	}
+unlock:
 	spin_unlock(&ino->i_lock);
 
 	pnfs_free_lseg_list(&free_me_list);
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 04050eb..8bd2dc2 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -858,6 +858,16 @@ _pnfs_return_layout(struct inode *ino)
 	empty = list_empty(&lo->plh_segs);
 	pnfs_clear_layoutcommit(ino, &tmp_list);
 	pnfs_mark_matching_lsegs_invalid(lo, &tmp_list, NULL);
+
+	if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
+		struct pnfs_layout_range range = {
+			.iomode		= IOMODE_ANY,
+			.offset		= 0,
+			.length		= NFS4_MAX_UINT64,
+		};
+		NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo, &range);
+	}
+
 	/* Don't send a LAYOUTRETURN if list was initially empty */
 	if (empty) {
 		spin_unlock(&ino->i_lock);
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index a4c530e..2c24942 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -94,6 +94,9 @@ struct pnfs_layoutdriver_type {
 	struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags);
 	void (*free_lseg) (struct pnfs_layout_segment *lseg);
 
+	void (*return_range) (struct pnfs_layout_hdr *lo,
+			      struct pnfs_layout_range *range);
+
 	/* test for nfs page cache coalescing */
 	const struct nfs_pageio_ops *pg_read_ops;
 	const struct nfs_pageio_ops *pg_write_ops;
-- 
1.9.1


  parent reply	other threads:[~2014-09-09 16:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09 16:40 pnfs block layout driver fixes V3 Christoph Hellwig
2014-09-09 16:40 ` [PATCH 1/9] pnfs: force a layout commit when encountering busy segments during recall Christoph Hellwig
2014-09-09 17:11   ` Anna Schumaker
2014-09-09 17:37     ` Christoph Hellwig
2014-09-09 16:40 ` [PATCH 2/9] pnfs: add flag to force read-modify-write in ->write_begin Christoph Hellwig
2014-09-09 17:16   ` Anna Schumaker
2014-09-09 16:40 ` Christoph Hellwig [this message]
2014-09-09 16:40 ` [PATCH 4/9] pnfs/blocklayout: remove read-modify-write handling in bl_write_pagelist Christoph Hellwig
2014-09-09 16:40 ` [PATCH 5/9] pnfs/blocklayout: don't set pages uptodate Christoph Hellwig
2014-09-09 16:40 ` [PATCH 6/9] pnfs/blocklayout: rewrite extent tracking Christoph Hellwig
2014-09-09 18:30   ` Anna Schumaker
2014-09-09 16:40 ` [PATCH 7/9] pnfs/blocklayout: implement the return_range method Christoph Hellwig
2014-09-09 16:40 ` [PATCH 8/9] pnfs/blocklayout: return layouts on setattr Christoph Hellwig
2014-09-09 16:40 ` [PATCH 9/9] pnfs/blocklayout: allocate separate pages for the layoutcommit payload Christoph Hellwig
2014-09-10 15:23 pnfs block layout driver fixes V4 Christoph Hellwig
2014-09-10 15:23 ` [PATCH 3/9] pnfs: add return_range method Christoph Hellwig
2014-09-11 13:54   ` Peng Tao
2014-09-11 15:20     ` Christoph Hellwig
2014-09-11 15:30       ` Peng Tao
2014-09-11 15:36         ` Christoph Hellwig
2014-09-12  2:22           ` Peng Tao
2014-09-13 19:38             ` Christoph Hellwig

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=1410280853-3964-4-git-send-email-hch@lst.de \
    --to=hch@lst.de \
    --cc=linux-nfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.