flexfilelayout.c (85a3685852d9ac7d92be9d824533c915a4597fa4) flexfilelayout.c (40c64c26a43494ba9982fd1b87dc54e3819566fc)
1/*
2 * Module for pnfs flexfile layout driver.
3 *
4 * Copyright (c) 2014, Primary Data, Inc. All rights reserved.
5 *
6 * Tao Peng <bergwolf@primarydata.com>
7 */
8
9#include <linux/nfs_fs.h>
10#include <linux/nfs_page.h>
11#include <linux/module.h>
12
13#include <linux/sunrpc/metrics.h>
1/*
2 * Module for pnfs flexfile layout driver.
3 *
4 * Copyright (c) 2014, Primary Data, Inc. All rights reserved.
5 *
6 * Tao Peng <bergwolf@primarydata.com>
7 */
8
9#include <linux/nfs_fs.h>
10#include <linux/nfs_page.h>
11#include <linux/module.h>
12
13#include <linux/sunrpc/metrics.h>
14#include <linux/nfs_idmap.h>
15
16#include "flexfilelayout.h"
17#include "../nfs4session.h"
14
15#include "flexfilelayout.h"
16#include "../nfs4session.h"
17#include "../nfs4idmap.h"
18#include "../internal.h"
19#include "../delegation.h"
20#include "../nfs4trace.h"
21#include "../iostat.h"
22#include "../nfs.h"
23
24#define NFSDBG_FACILITY NFSDBG_PNFS_LD
25

--- 860 unchanged lines hidden (view full) ---

886 *
887 * Flexlayout client should treat DS replied FILE_SYNC as DATA_SYNC, so
888 * to follow http://www.rfc-editor.org/errata_search.php?rfc=5661&eid=2751
889 * we always send layoutcommit after DS writes.
890 */
891static void
892ff_layout_set_layoutcommit(struct nfs_pgio_header *hdr)
893{
18#include "../internal.h"
19#include "../delegation.h"
20#include "../nfs4trace.h"
21#include "../iostat.h"
22#include "../nfs.h"
23
24#define NFSDBG_FACILITY NFSDBG_PNFS_LD
25

--- 860 unchanged lines hidden (view full) ---

886 *
887 * Flexlayout client should treat DS replied FILE_SYNC as DATA_SYNC, so
888 * to follow http://www.rfc-editor.org/errata_search.php?rfc=5661&eid=2751
889 * we always send layoutcommit after DS writes.
890 */
891static void
892ff_layout_set_layoutcommit(struct nfs_pgio_header *hdr)
893{
894 pnfs_set_layoutcommit(hdr);
894 pnfs_set_layoutcommit(hdr->inode, hdr->lseg,
895 hdr->mds_offset + hdr->res.count);
895 dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino,
896 (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb);
897}
898
899static bool
900ff_layout_reset_to_mds(struct pnfs_layout_segment *lseg, int idx)
901{
902 /* No mirroring for now */

--- 166 unchanged lines hidden (view full) ---

1069 pnfs_generic_prepare_to_resend_writes(data);
1070 return -EAGAIN;
1071 case -EAGAIN:
1072 rpc_restart_call_prepare(task);
1073 return -EAGAIN;
1074 }
1075
1076 if (data->verf.committed == NFS_UNSTABLE)
896 dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino,
897 (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb);
898}
899
900static bool
901ff_layout_reset_to_mds(struct pnfs_layout_segment *lseg, int idx)
902{
903 /* No mirroring for now */

--- 166 unchanged lines hidden (view full) ---

1070 pnfs_generic_prepare_to_resend_writes(data);
1071 return -EAGAIN;
1072 case -EAGAIN:
1073 rpc_restart_call_prepare(task);
1074 return -EAGAIN;
1075 }
1076
1077 if (data->verf.committed == NFS_UNSTABLE)
1077 pnfs_commit_set_layoutcommit(data);
1078 pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb);
1078
1079 return 0;
1080}
1081
1082static int ff_layout_write_prepare_common(struct rpc_task *task,
1083 struct nfs_pgio_header *hdr)
1084{
1085 if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) {

--- 323 unchanged lines hidden (view full) ---

1409
1410 if (layout == NULL)
1411 return NULL;
1412
1413 return &FF_LAYOUT_FROM_HDR(layout)->commit_info;
1414}
1415
1416static void
1079
1080 return 0;
1081}
1082
1083static int ff_layout_write_prepare_common(struct rpc_task *task,
1084 struct nfs_pgio_header *hdr)
1085{
1086 if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) {

--- 323 unchanged lines hidden (view full) ---

1410
1411 if (layout == NULL)
1412 return NULL;
1413
1414 return &FF_LAYOUT_FROM_HDR(layout)->commit_info;
1415}
1416
1417static void
1417ff_layout_free_deveiceid_node(struct nfs4_deviceid_node *d)
1418ff_layout_free_deviceid_node(struct nfs4_deviceid_node *d)
1418{
1419 nfs4_ff_layout_free_deviceid(container_of(d, struct nfs4_ff_layout_ds,
1420 id_node));
1421}
1422
1423static int ff_layout_encode_ioerr(struct nfs4_flexfile_layout *flo,
1424 struct xdr_stream *xdr,
1425 const struct nfs4_layoutreturn_args *args)

--- 67 unchanged lines hidden (view full) ---

1493 .owner = THIS_MODULE,
1494 .alloc_layout_hdr = ff_layout_alloc_layout_hdr,
1495 .free_layout_hdr = ff_layout_free_layout_hdr,
1496 .alloc_lseg = ff_layout_alloc_lseg,
1497 .free_lseg = ff_layout_free_lseg,
1498 .pg_read_ops = &ff_layout_pg_read_ops,
1499 .pg_write_ops = &ff_layout_pg_write_ops,
1500 .get_ds_info = ff_layout_get_ds_info,
1419{
1420 nfs4_ff_layout_free_deviceid(container_of(d, struct nfs4_ff_layout_ds,
1421 id_node));
1422}
1423
1424static int ff_layout_encode_ioerr(struct nfs4_flexfile_layout *flo,
1425 struct xdr_stream *xdr,
1426 const struct nfs4_layoutreturn_args *args)

--- 67 unchanged lines hidden (view full) ---

1494 .owner = THIS_MODULE,
1495 .alloc_layout_hdr = ff_layout_alloc_layout_hdr,
1496 .free_layout_hdr = ff_layout_free_layout_hdr,
1497 .alloc_lseg = ff_layout_alloc_lseg,
1498 .free_lseg = ff_layout_free_lseg,
1499 .pg_read_ops = &ff_layout_pg_read_ops,
1500 .pg_write_ops = &ff_layout_pg_write_ops,
1501 .get_ds_info = ff_layout_get_ds_info,
1501 .free_deviceid_node = ff_layout_free_deveiceid_node,
1502 .free_deviceid_node = ff_layout_free_deviceid_node,
1502 .mark_request_commit = pnfs_layout_mark_request_commit,
1503 .clear_request_commit = pnfs_generic_clear_request_commit,
1504 .scan_commit_lists = pnfs_generic_scan_commit_lists,
1505 .recover_commit_reqs = pnfs_generic_recover_commit_reqs,
1506 .commit_pagelist = ff_layout_commit_pagelist,
1507 .read_pagelist = ff_layout_read_pagelist,
1508 .write_pagelist = ff_layout_write_pagelist,
1509 .alloc_deviceid_node = ff_layout_alloc_deviceid_node,
1510 .encode_layoutreturn = ff_layout_encode_layoutreturn,
1503 .mark_request_commit = pnfs_layout_mark_request_commit,
1504 .clear_request_commit = pnfs_generic_clear_request_commit,
1505 .scan_commit_lists = pnfs_generic_scan_commit_lists,
1506 .recover_commit_reqs = pnfs_generic_recover_commit_reqs,
1507 .commit_pagelist = ff_layout_commit_pagelist,
1508 .read_pagelist = ff_layout_read_pagelist,
1509 .write_pagelist = ff_layout_write_pagelist,
1510 .alloc_deviceid_node = ff_layout_alloc_deviceid_node,
1511 .encode_layoutreturn = ff_layout_encode_layoutreturn,
1512 .sync = pnfs_nfs_generic_sync,
1511};
1512
1513static int __init nfs4flexfilelayout_init(void)
1514{
1515 printk(KERN_INFO "%s: NFSv4 Flexfile Layout Driver Registering...\n",
1516 __func__);
1517 return pnfs_register_layoutdriver(&flexfilelayout_type);
1518}

--- 15 unchanged lines hidden ---
1513};
1514
1515static int __init nfs4flexfilelayout_init(void)
1516{
1517 printk(KERN_INFO "%s: NFSv4 Flexfile Layout Driver Registering...\n",
1518 __func__);
1519 return pnfs_register_layoutdriver(&flexfilelayout_type);
1520}

--- 15 unchanged lines hidden ---