From patchwork Tue Jun 7 17:28:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Rees X-Patchwork-Id: 858112 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 p57HQgVd007977 for ; Tue, 7 Jun 2011 17:28:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755388Ab1FGR2F (ORCPT ); Tue, 7 Jun 2011 13:28:05 -0400 Received: from int-mailstore01.merit.edu ([207.75.116.232]:53275 "EHLO int-mailstore01.merit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754412Ab1FGR2F (ORCPT ); Tue, 7 Jun 2011 13:28:05 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by int-mailstore01.merit.edu (Postfix) with ESMTP id A4C3830852CE; Tue, 7 Jun 2011 13:28:03 -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 yoKmwIuVO+4R; Tue, 7 Jun 2011 13:28:03 -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 D8AF73055B74; Tue, 7 Jun 2011 13:28:02 -0400 (EDT) Date: Tue, 7 Jun 2011 13:28:02 -0400 From: Jim Rees To: Benny Halevy Cc: linux-nfs@vger.kernel.org, peter honeyman Subject: [PATCH 19/88] pnfsblock: layout 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:06 +0000 (UTC) From: Fred Isaman Allocate the empty list-heads that will hold all the extent data for the layout. Signed-off-by: Fred Isaman [pnfs: move pnfs_layout_type inline in nfs_inode] Signed-off-by: Benny Halevy --- fs/nfs/blocklayout/blocklayout.c | 33 ++++++++++++++++++++++++++++++++- fs/nfs/blocklayout/blocklayout.h | 25 +++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletions(-) diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index ebaa48a..677836c 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c @@ -83,18 +83,49 @@ bl_write_pagelist(struct pnfs_layout_type *lo, return PNFS_NOT_ATTEMPTED; } +/* STUB */ +static void +release_extents(struct pnfs_block_layout *bl, + struct nfs4_pnfs_layout_segment *range) +{ + return; +} + +/* STUB */ +static void +release_inval_marks(void) +{ + return; +} + +/* Note we are relying on caller locking to prevent nasty races. */ static void bl_free_layout(void *p) { + struct pnfs_block_layout *bl = p; + dprintk("%s enter\n", __func__); + release_extents(bl, NULL); + release_inval_marks(); + kfree(bl); return; } static void * bl_alloc_layout(struct pnfs_mount_type *mtype, struct inode *inode) { + struct pnfs_block_layout *bl; + dprintk("%s enter\n", __func__); - return NULL; + bl = kzalloc(sizeof(*bl), GFP_KERNEL); + if (!bl) + return NULL; + spin_lock_init(&bl->bl_ext_lock); + INIT_LIST_HEAD(&bl->bl_extents[0]); + INIT_LIST_HEAD(&bl->bl_extents[1]); + bl->bl_blocksize = NFS_SERVER(inode)->pnfs_blksize >> 9; + INIT_INVAL_MARKS(&bl->bl_inval, bl->bl_blocksize); + return bl; } static void diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h index d695f8e..dd25f1a 100644 --- a/fs/nfs/blocklayout/blocklayout.h +++ b/fs/nfs/blocklayout/blocklayout.h @@ -99,6 +99,31 @@ struct pnfs_blk_sig { struct pnfs_blk_sig_comp si_comps[PNFS_BLOCK_MAX_SIG_COMP]; }; +struct pnfs_inval_markings { + /* STUB */ +}; + +static inline void +INIT_INVAL_MARKS(struct pnfs_inval_markings *marks, sector_t blocksize) +{ + /* STUB */ +} + +enum extentclass4 { + RW_EXTENT = 0, /* READWRTE and INVAL */ + RO_EXTENT = 1, /* READ and NONE */ + EXTENT_LISTS = 2, +}; + +struct pnfs_block_layout { + struct pnfs_inval_markings bl_inval; /* tracks INVAL->RW transition */ + spinlock_t bl_ext_lock; /* Protects list manipulation */ + struct list_head bl_extents[EXTENT_LISTS]; /* R and RW extents */ + sector_t bl_blocksize; /* Server blocksize in sectors */ +}; + +#define BLK_LO2EXT(lo) ((struct pnfs_block_layout *)lo->ld_data) + uint32_t *blk_overflow(uint32_t *p, uint32_t *end, size_t nbytes); #define BLK_READBUF(p, e, nbytes) do { \