pnfs: encode_layoutcommit
authorBenny Halevy <bhalevy@panasas.com>
Sun, 22 May 2011 16:53:48 +0000 (19:53 +0300)
committerBoaz Harrosh <bharrosh@panasas.com>
Sun, 29 May 2011 17:55:00 +0000 (20:55 +0300)
Add a layout driver method to encode the layout type specific
opaque part of layout commit in-line in the xdr stream.

Currently, the pnfs-objects layout driver uses it to encode metadata hints
to the MDS and the blocks layout driver to commit provisionally allocated
extents to the file.

Signed-off-by: Benny Halevy <bhalevy@panasas.com>
fs/nfs/nfs4xdr.c
fs/nfs/pnfs.h

index d464badc00673057898db1bba7cb345ea20555bd..d869a5e5464b46cf0276e8df3466dcfafd83acda 100644 (file)
@@ -1875,6 +1875,7 @@ encode_layoutget(struct xdr_stream *xdr,
 
 static int
 encode_layoutcommit(struct xdr_stream *xdr,
+                   struct inode *inode,
                    const struct nfs4_layoutcommit_args *args,
                    struct compound_hdr *hdr)
 {
@@ -1883,7 +1884,7 @@ encode_layoutcommit(struct xdr_stream *xdr,
        dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten,
                NFS_SERVER(args->inode)->pnfs_curr_ld->id);
 
-       p = reserve_space(xdr, 48 + NFS4_STATEID_SIZE);
+       p = reserve_space(xdr, 44 + NFS4_STATEID_SIZE);
        *p++ = cpu_to_be32(OP_LAYOUTCOMMIT);
        /* Only whole file layouts */
        p = xdr_encode_hyper(p, 0); /* offset */
@@ -1894,7 +1895,14 @@ encode_layoutcommit(struct xdr_stream *xdr,
        p = xdr_encode_hyper(p, args->lastbytewritten);
        *p++ = cpu_to_be32(0); /* Never send time_modify_changed */
        *p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */
-       *p++ = cpu_to_be32(0); /* no file layout payload */
+
+       if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit)
+               NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit(
+                       NFS_I(inode)->layout, xdr, args);
+       else {
+               p = reserve_space(xdr, 4);
+               *p = cpu_to_be32(0); /* no layout-type payload */
+       }
 
        hdr->nops++;
        hdr->replen += decode_layoutcommit_maxsz;
@@ -2751,6 +2759,8 @@ static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req,
                                      struct xdr_stream *xdr,
                                      struct nfs4_layoutcommit_args *args)
 {
+       struct nfs4_layoutcommit_data *data =
+               container_of(args, struct nfs4_layoutcommit_data, args);
        struct compound_hdr hdr = {
                .minorversion = nfs4_xdr_minorversion(&args->seq_args),
        };
@@ -2758,7 +2768,7 @@ static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req,
        encode_compound_hdr(xdr, req, &hdr);
        encode_sequence(xdr, &args->seq_args, &hdr);
        encode_putfh(xdr, NFS_FH(args->inode), &hdr);
-       encode_layoutcommit(xdr, args, &hdr);
+       encode_layoutcommit(xdr, data->args.inode, args, &hdr);
        encode_getfattr(xdr, args->bitmask, &hdr);
        encode_nops(&hdr);
 }
index 1b6b207a8806e0bcdfadb7fbdd91fe61e8c09f1b..3fda97146777777cddbec6ecd62b2f1d8be437f5 100644 (file)
@@ -108,6 +108,10 @@ struct pnfs_layoutdriver_type {
        void (*encode_layoutreturn) (struct pnfs_layout_hdr *layoutid,
                                     struct xdr_stream *xdr,
                                     const struct nfs4_layoutreturn_args *args);
+
+       void (*encode_layoutcommit) (struct pnfs_layout_hdr *layoutid,
+                                    struct xdr_stream *xdr,
+                                    const struct nfs4_layoutcommit_args *args);
 };
 
 struct pnfs_layout_hdr {