From patchwork Sun Jun 12 23:43:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Rees X-Patchwork-Id: 873292 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5CNhq9m007930 for ; Sun, 12 Jun 2011 23:44:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754262Ab1FLXnz (ORCPT ); Sun, 12 Jun 2011 19:43:55 -0400 Received: from int-mailstore01.merit.edu ([207.75.116.232]:60566 "EHLO int-mailstore01.merit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754246Ab1FLXnz (ORCPT ); Sun, 12 Jun 2011 19:43:55 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by int-mailstore01.merit.edu (Postfix) with ESMTP id DE5B3308EFA1; Sun, 12 Jun 2011 19:43:54 -0400 (EDT) X-Virus-Scanned: amavisd-new at int-mailstore01.merit.edu Received: from int-mailstore01.merit.edu ([127.0.0.1]) by localhost (int-mailstore01.merit.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sr5qx0aXLIHC; Sun, 12 Jun 2011 19:43:54 -0400 (EDT) Received: from merit.edu (74-126-0-171.static.123.net [74.126.0.171]) by int-mailstore01.merit.edu (Postfix) with ESMTPSA id 49F2630852E8; Sun, 12 Jun 2011 19:43:54 -0400 (EDT) X-Mailbox-Line: From 9f228c643de1f0378835d6ec9a493c1320bf001d Mon Sep 17 00:00:00 2001 Message-Id: <9f228c643de1f0378835d6ec9a493c1320bf001d.1307921137.git.rees@umich.edu> In-Reply-To: References: Date: Sun, 12 Jun 2011 19:43:52 -0400 Subject: [PATCH 03/34] pnfs: let layoutcommit code handle multiple segments From: Jim Rees To: linux-nfs@vger.kernel.org Cc: peter honeyman Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 12 Jun 2011 23:44:15 +0000 (UTC) From: Peng Tao Some layout driver like block will have multiple segments. Generic code should be able to handle it. Signed-off-by: Peng Tao --- fs/nfs/pnfs.c | 17 +++++++++++++---- fs/nfs/pnfs.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index e3d618b..f03a5e0 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -892,7 +892,7 @@ pnfs_find_lseg(struct pnfs_layout_hdr *lo, dprintk("%s:Begin\n", __func__); assert_spin_locked(&lo->plh_inode->i_lock); - list_for_each_entry(lseg, &lo->plh_segs, pls_list) { + list_for_each_entry_reverse(lseg, &lo->plh_segs, pls_list) { if (test_bit(NFS_LSEG_VALID, &lseg->pls_flags) && is_matching_lseg(&lseg->pls_range, range)) { ret = get_lseg(lseg); @@ -1193,10 +1193,18 @@ pnfs_try_to_read_data(struct nfs_read_data *rdata, static struct pnfs_layout_segment *pnfs_list_write_lseg(struct inode *inode) { struct pnfs_layout_segment *lseg, *rv = NULL; + loff_t max_pos = 0; + + list_for_each_entry(lseg, &NFS_I(inode)->layout->plh_segs, pls_list) { + if (lseg->pls_range.iomode == IOMODE_RW) { + if (max_pos < lseg->pls_end_pos) + max_pos = lseg->pls_end_pos; + if (test_and_clear_bit(NFS_LSEG_LAYOUTCOMMIT, &lseg->pls_flags)) + rv = lseg; + } + } + rv->pls_end_pos = max_pos; - list_for_each_entry(lseg, &NFS_I(inode)->layout->plh_segs, pls_list) - if (lseg->pls_range.iomode == IOMODE_RW) - rv = lseg; return rv; } @@ -1211,6 +1219,7 @@ pnfs_set_layoutcommit(struct nfs_write_data *wdata) if (!test_and_set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) { /* references matched in nfs4_layoutcommit_release */ get_lseg(wdata->lseg); + set_bit(NFS_LSEG_LAYOUTCOMMIT, &wdata->lseg->pls_flags); wdata->lseg->pls_lc_cred = get_rpccred(wdata->args.context->state->owner->so_cred); mark_as_dirty = true; diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index b071b56..a3fc0f2 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -36,6 +36,7 @@ enum { NFS_LSEG_VALID = 0, /* cleared when lseg is recalled/returned */ NFS_LSEG_ROC, /* roc bit received from server */ + NFS_LSEG_LAYOUTCOMMIT, /* layoutcommit bit set for layoutcommit */ }; struct pnfs_layout_segment {