From: Fred Isaman <iisaman@xxxxxxxxxxxxxx> Adds the minimal structure for a pnfs block layout driver, with all function pointers aimed at stubs. [pnfsblock: SQUASHME: adjust to API change] Signed-off-by: Fred Isaman <iisaman@xxxxxxxxxxxxxx> [pnfs: move pnfs_layout_type inline in nfs_inode] Signed-off-by: Benny Halevy <bhalevy@xxxxxxxxxxx> [blocklayout: encode_layoutcommit implementation] Signed-off-by: Boaz Harrosh <bharrosh@xxxxxxxxxxx> Signed-off-by: Benny Halevy <bhalevy@xxxxxxxxxxx> --- fs/nfs/blocklayout/Makefile | 4 +- fs/nfs/blocklayout/blocklayout.c | 224 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 fs/nfs/blocklayout/blocklayout.c diff --git a/fs/nfs/blocklayout/Makefile b/fs/nfs/blocklayout/Makefile index f214c1c..6bf49cd 100644 --- a/fs/nfs/blocklayout/Makefile +++ b/fs/nfs/blocklayout/Makefile @@ -1,5 +1,5 @@ # # Makefile for the pNFS block layout driver kernel module # -obj-$(CONFIG_PNFS_BLOCK) += -blocklayoutdriver-objs := +obj-$(CONFIG_PNFS_BLOCK) += blocklayoutdriver.o +blocklayoutdriver-objs := blocklayout.o diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c new file mode 100644 index 0000000..1312849 --- /dev/null +++ b/fs/nfs/blocklayout/blocklayout.c @@ -0,0 +1,224 @@ +/* + * linux/fs/nfs/blocklayout/blocklayout.c + * + * Module for the NFSv4.1 pNFS block layout driver. + * + * Copyright (c) 2006 The Regents of the University of Michigan. + * All rights reserved. + * + * Andy Adamson <andros@xxxxxxxxxxxxxx> + * Fred Isaman <iisaman@xxxxxxxxx> + * + * permission is granted to use, copy, create derivative works and + * redistribute this software and such derivative works for any purpose, + * so long as the name of the university of michigan is not used in + * any advertising or publicity pertaining to the use or distribution + * of this software without specific, written prior authorization. if + * the above copyright notice or any other identification of the + * university of michigan is included in any copy of any portion of + * this software, then the disclaimer below must also be included. + * + * this software is provided as is, without representation from the + * university of michigan as to its fitness for any purpose, and without + * warranty by the university of michigan of any kind, either express + * or implied, including without limitation the implied warranties of + * merchantability and fitness for a particular purpose. the regents + * of the university of michigan shall not be liable for any damages, + * including special, indirect, incidental, or consequential damages, + * with respect to any claim arising out or in connection with the use + * of the software, even if it has been or is hereafter advised of the + * possibility of such damages. + */ +#include <linux/module.h> +#include <linux/init.h> + +#include <linux/nfs_fs.h> +#include <linux/pnfs_xdr.h> /* Needed by nfs4_pnfs.h */ +#include <linux/nfs4_pnfs.h> + +#define NFSDBG_FACILITY NFSDBG_PNFS_LD + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Andy Adamson <andros@xxxxxxxxxxxxxx>"); +MODULE_DESCRIPTION("The NFSv4.1 pNFS Block layout driver"); + +/* Callback operations to the pNFS client */ +struct pnfs_client_operations *pnfs_callback_ops; + +static enum pnfs_try_status +bl_commit(struct pnfs_layout_type *lo, + int sync, + struct nfs_write_data *nfs_data) +{ + dprintk("%s enter\n", __func__); + return PNFS_NOT_ATTEMPTED; +} + +static enum pnfs_try_status +bl_read_pagelist(struct pnfs_layout_type *lo, + struct page **pages, + unsigned int pgbase, + unsigned nr_pages, + loff_t offset, + size_t count, + struct nfs_read_data *nfs_data) +{ + dprintk("%s enter\n", __func__); + return PNFS_NOT_ATTEMPTED; +} + +/* FRED - It can indicate bytes written in wdata->res.count. + * It can indicate error status in wdata->task.tk_status. + */ +static enum pnfs_try_status +bl_write_pagelist(struct pnfs_layout_type *lo, + struct page **pages, + unsigned int pgbase, + unsigned nr_pages, + loff_t offset, + size_t count, + int sync, + struct nfs_write_data *wdata) +{ + dprintk("%s enter - just using nfs\n", __func__); + return PNFS_NOT_ATTEMPTED; +} + +static void +bl_free_layout(void *p) +{ + dprintk("%s enter\n", __func__); + return; +} + +static void * +bl_alloc_layout(struct pnfs_mount_type *mtype, struct inode *inode) +{ + dprintk("%s enter\n", __func__); + return NULL; +} + +static void +bl_free_lseg(struct pnfs_layout_segment *lseg) +{ + dprintk("%s enter\n", __func__); + return; +} + +static struct pnfs_layout_segment * +bl_alloc_lseg(struct pnfs_layout_type *lo, + struct nfs4_pnfs_layoutget_res *lgr) +{ + dprintk("%s enter\n", __func__); + return NULL; +} + +static int +bl_setup_layoutcommit(struct pnfs_layout_type *lo, + struct pnfs_layoutcommit_arg *arg) +{ + dprintk("%s enter\n", __func__); + return 0; +} + +static void +bl_encode_layoutcommit(struct pnfs_layout_type *lo, struct xdr_stream *xdr, + const struct pnfs_layoutcommit_arg *arg) +{ + dprintk("%s enter\n", __func__); +} + +static void +bl_cleanup_layoutcommit(struct pnfs_layout_type *lo, + struct pnfs_layoutcommit_arg *arg, int status) +{ + dprintk("%s enter\n", __func__); +} + +static struct pnfs_mount_type * +bl_initialize_mountpoint(struct super_block *sb, struct nfs_fh *fh) +{ + dprintk("%s enter\n", __func__); + return NULL; +} + +static int +bl_uninitialize_mountpoint(struct pnfs_mount_type *mtype) +{ + dprintk("%s enter\n", __func__); + return 0; +} + +static ssize_t +bl_get_stripesize(struct pnfs_layout_type *lo) +{ + dprintk("%s enter\n", __func__); + return 0; +} + +static ssize_t +bl_get_io_threshold(struct pnfs_layout_type *lo, struct inode *inode) +{ + dprintk("%s enter\n", __func__); + return 0; +} + +/* This is called by nfs_can_coalesce_requests via nfs_pageio_do_add_request. + * Should return False if there is a reason requests can not be coalesced, + * otherwise, should default to returning True. + */ +static int +bl_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, + struct nfs_page *req) +{ + dprintk("%s enter\n", __func__); + return 1; +} + +static struct layoutdriver_io_operations blocklayout_io_operations = { + .commit = bl_commit, + .read_pagelist = bl_read_pagelist, + .write_pagelist = bl_write_pagelist, + .alloc_layout = bl_alloc_layout, + .free_layout = bl_free_layout, + .alloc_lseg = bl_alloc_lseg, + .free_lseg = bl_free_lseg, + .setup_layoutcommit = bl_setup_layoutcommit, + .encode_layoutcommit = bl_encode_layoutcommit, + .cleanup_layoutcommit = bl_cleanup_layoutcommit, + .initialize_mountpoint = bl_initialize_mountpoint, + .uninitialize_mountpoint = bl_uninitialize_mountpoint, +}; + +static struct layoutdriver_policy_operations blocklayout_policy_operations = { + .get_stripesize = bl_get_stripesize, + .get_read_threshold = bl_get_io_threshold, + .get_write_threshold = bl_get_io_threshold, + .pg_test = bl_pg_test, +}; + +static struct pnfs_layoutdriver_type blocklayout_type = { + .id = LAYOUT_BLOCK_VOLUME, + .name = "LAYOUT_BLOCK_VOLUME", + .ld_io_ops = &blocklayout_io_operations, + .ld_policy_ops = &blocklayout_policy_operations, +}; + +static int __init nfs4blocklayout_init(void) +{ + dprintk("%s: NFSv4 Block Layout Driver Registering...\n", __func__); + + pnfs_callback_ops = pnfs_register_layoutdriver(&blocklayout_type); + return 0; +} + +static void __exit nfs4blocklayout_exit(void) +{ + dprintk("%s: NFSv4 Block Layout Driver Unregistering...\n", + __func__); + + pnfs_unregister_layoutdriver(&blocklayout_type); +} + +module_init(nfs4blocklayout_init); +module_exit(nfs4blocklayout_exit); -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html