From patchwork Tue Jun 7 17:28:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Rees X-Patchwork-Id: 858132 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p57HQgVf007977 for ; Tue, 7 Jun 2011 17:28:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755596Ab1FGR2R (ORCPT ); Tue, 7 Jun 2011 13:28:17 -0400 Received: from int-mailstore01.merit.edu ([207.75.116.232]:53361 "EHLO int-mailstore01.merit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754412Ab1FGR2Q (ORCPT ); Tue, 7 Jun 2011 13:28:16 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by int-mailstore01.merit.edu (Postfix) with ESMTP id 600A5305CF58; Tue, 7 Jun 2011 13:28:16 -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 QWWklg9rmmNf; Tue, 7 Jun 2011 13:28:16 -0400 (EDT) Received: from merit.edu (host-17.subnet-17.med.umich.edu [141.214.17.17]) by int-mailstore01.merit.edu (Postfix) with ESMTPSA id E402A3055B74; Tue, 7 Jun 2011 13:28:15 -0400 (EDT) Date: Tue, 7 Jun 2011 13:28:15 -0400 From: Jim Rees To: Benny Halevy Cc: linux-nfs@vger.kernel.org, peter honeyman Subject: [PATCH 21/88] pnfsblock: lseg alloc and free Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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 (demeter2.kernel.org [140.211.167.43]); Tue, 07 Jun 2011 17:28:17 +0000 (UTC) From: Fred Isaman Signed-off-by: Fred Isaman [pnfsblock: fix bug getting pnfs_layout_type in translate_devid().] Signed-off-by: Tao Guo Signed-off-by: Benny Halevy --- fs/nfs/blocklayout/blocklayout.c | 29 +++++++++++++++++++++++++++-- fs/nfs/blocklayout/blocklayout.h | 3 +++ fs/nfs/blocklayout/blocklayoutdev.c | 9 +++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index fb06f3a..f54e9a9 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c @@ -145,15 +145,40 @@ static void bl_free_lseg(struct pnfs_layout_segment *lseg) { dprintk("%s enter\n", __func__); - return; + kfree(lseg); } +/* Because the generic infrastructure does not correctly merge layouts, + * we pretty much ignore lseg, and store all data layout wide, so we + * can correctly merge. Eventually we should push some correct merge + * behavior up to the generic code, as the current behavior tends to + * cause lots of unnecessary overlapping LAYOUTGET requests. + */ static struct pnfs_layout_segment * bl_alloc_lseg(struct pnfs_layout_type *lo, struct nfs4_pnfs_layoutget_res *lgr) { + struct pnfs_layout_segment *lseg; + int status; + dprintk("%s enter\n", __func__); - return NULL; + lseg = kzalloc(sizeof(*lseg) + 0, GFP_KERNEL); + if (!lseg) + return NULL; + status = nfs4_blk_process_layoutget(lo, lgr); + if (status) { + /* We don't want to call the full-blown bl_free_lseg, + * since on error extents were not touched. + */ + /* STUB - we really want to distinguish between 2 error + * conditions here. This lseg failed, but lo data structures + * are OK, or we hosed the lo data structures. The calling + * code probably needs to distinguish this too. + */ + kfree(lseg); + return ERR_PTR(status); + } + return lseg; } static int diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h index 4e6f8fc..bcf85be 100644 --- a/fs/nfs/blocklayout/blocklayout.h +++ b/fs/nfs/blocklayout/blocklayout.h @@ -142,6 +142,7 @@ struct pnfs_block_layout { sector_t bl_blocksize; /* Server blocksize in sectors */ }; +#define BLK_LSEG2EXT(lseg) ((struct pnfs_block_layout *)lseg->layout->ld_data) #define BLK_LO2EXT(lo) ((struct pnfs_block_layout *)lo->ld_data) uint32_t *blk_overflow(uint32_t *p, uint32_t *end, size_t nbytes); @@ -183,6 +184,8 @@ int nfs4_blkdev_put(struct block_device *bdev); struct pnfs_block_dev *nfs4_blk_decode_device(struct super_block *sb, struct pnfs_device *dev, struct list_head *sdlist); +int nfs4_blk_process_layoutget(struct pnfs_layout_type *lo, + struct nfs4_pnfs_layoutget_res *lgr); int nfs4_blk_create_scsi_disk_list(struct list_head *); void nfs4_blk_destroy_disk_list(struct list_head *); /* blocklayoutdm.c */ diff --git a/fs/nfs/blocklayout/blocklayoutdev.c b/fs/nfs/blocklayout/blocklayoutdev.c index 0ea44aa..818cc1c 100644 --- a/fs/nfs/blocklayout/blocklayoutdev.c +++ b/fs/nfs/blocklayout/blocklayoutdev.c @@ -553,3 +553,12 @@ nfs4_blk_decode_device(struct super_block *sb, kfree(vols); return rv; } + +/* XDR decode pnfs_block_layout4 structure */ +int +nfs4_blk_process_layoutget(struct pnfs_layout_type *lo, + struct nfs4_pnfs_layoutget_res *lgr) +{ + /* STUB */ + return -EIO; +}