aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2011-05-22 12:54:13 -0400
committerBoaz Harrosh <bharrosh@panasas.com>2011-05-29 13:55:00 -0400
commita0fe8bf427f4987d7b82678292ca03cfd7331467 (patch)
treed995bd164b03dde89da24af979931c2490fe9414
parentac7db7264ac3314cae09893bc838fcb7e83267a4 (diff)
pnfs-obj: objlayout_encode_layoutcommit implementation
* Define API for io-engines to report delta_space_used in IOs * Encode the osd-layout specific information of the layoutcommit XDR buffer. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: Benny Halevy <bhalevy@panasas.com>
-rw-r--r--fs/nfs/objlayout/objio_osd.c1
-rw-r--r--fs/nfs/objlayout/objlayout.c30
-rw-r--r--fs/nfs/objlayout/objlayout.h30
3 files changed, 61 insertions, 0 deletions
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c
index 8bca5e13f3ef..3be124160e97 100644
--- a/fs/nfs/objlayout/objio_osd.c
+++ b/fs/nfs/objlayout/objio_osd.c
@@ -1018,6 +1018,7 @@ static struct pnfs_layoutdriver_type objlayout_type = {
1018 1018
1019 .free_deviceid_node = objio_free_deviceid_node, 1019 .free_deviceid_node = objio_free_deviceid_node,
1020 1020
1021 .encode_layoutcommit = objlayout_encode_layoutcommit,
1021 .encode_layoutreturn = objlayout_encode_layoutreturn, 1022 .encode_layoutreturn = objlayout_encode_layoutreturn,
1022}; 1023};
1023 1024
diff --git a/fs/nfs/objlayout/objlayout.c b/fs/nfs/objlayout/objlayout.c
index f7caecff6b4d..dc3956c0de80 100644
--- a/fs/nfs/objlayout/objlayout.c
+++ b/fs/nfs/objlayout/objlayout.c
@@ -225,6 +225,7 @@ objlayout_iodone(struct objlayout_io_state *state)
225 struct objlayout *objlay = OBJLAYOUT(state->lseg->pls_layout); 225 struct objlayout *objlay = OBJLAYOUT(state->lseg->pls_layout);
226 226
227 spin_lock(&objlay->lock); 227 spin_lock(&objlay->lock);
228 objlay->delta_space_valid = OBJ_DSU_INVALID;
228 list_add(&objlay->err_list, &state->err_list); 229 list_add(&objlay->err_list, &state->err_list);
229 spin_unlock(&objlay->lock); 230 spin_unlock(&objlay->lock);
230 } 231 }
@@ -433,6 +434,35 @@ objlayout_write_pagelist(struct nfs_write_data *wdata,
433 return PNFS_ATTEMPTED; 434 return PNFS_ATTEMPTED;
434} 435}
435 436
437void
438objlayout_encode_layoutcommit(struct pnfs_layout_hdr *pnfslay,
439 struct xdr_stream *xdr,
440 const struct nfs4_layoutcommit_args *args)
441{
442 struct objlayout *objlay = OBJLAYOUT(pnfslay);
443 struct pnfs_osd_layoutupdate lou;
444 __be32 *start;
445
446 dprintk("%s: Begin\n", __func__);
447
448 spin_lock(&objlay->lock);
449 lou.dsu_valid = (objlay->delta_space_valid == OBJ_DSU_VALID);
450 lou.dsu_delta = objlay->delta_space_used;
451 objlay->delta_space_used = 0;
452 objlay->delta_space_valid = OBJ_DSU_INIT;
453 lou.olu_ioerr_flag = !list_empty(&objlay->err_list);
454 spin_unlock(&objlay->lock);
455
456 start = xdr_reserve_space(xdr, 4);
457
458 BUG_ON(pnfs_osd_xdr_encode_layoutupdate(xdr, &lou));
459
460 *start = cpu_to_be32((xdr->p - start - 1) * 4);
461
462 dprintk("%s: Return delta_space_used %lld err %d\n", __func__,
463 lou.dsu_delta, lou.olu_ioerr_flag);
464}
465
436static int 466static int
437err_prio(u32 oer_errno) 467err_prio(u32 oer_errno)
438{ 468{
diff --git a/fs/nfs/objlayout/objlayout.h b/fs/nfs/objlayout/objlayout.h
index b0bb975058e4..a8244c8e042d 100644
--- a/fs/nfs/objlayout/objlayout.h
+++ b/fs/nfs/objlayout/objlayout.h
@@ -51,6 +51,14 @@
51struct objlayout { 51struct objlayout {
52 struct pnfs_layout_hdr pnfs_layout; 52 struct pnfs_layout_hdr pnfs_layout;
53 53
54 /* for layout_commit */
55 enum osd_delta_space_valid_enum {
56 OBJ_DSU_INIT = 0,
57 OBJ_DSU_VALID,
58 OBJ_DSU_INVALID,
59 } delta_space_valid;
60 s64 delta_space_used; /* consumed by write ops */
61
54 /* for layout_return */ 62 /* for layout_return */
55 spinlock_t lock; 63 spinlock_t lock;
56 struct list_head err_list; 64 struct list_head err_list;
@@ -119,6 +127,23 @@ extern void objlayout_io_set_result(struct objlayout_io_state *state,
119 unsigned index, struct pnfs_osd_objid *pooid, 127 unsigned index, struct pnfs_osd_objid *pooid,
120 int osd_error, u64 offset, u64 length, bool is_write); 128 int osd_error, u64 offset, u64 length, bool is_write);
121 129
130static inline void
131objlayout_add_delta_space_used(struct objlayout_io_state *state, s64 space_used)
132{
133 struct objlayout *objlay = OBJLAYOUT(state->lseg->pls_layout);
134
135 /* If one of the I/Os errored out and the delta_space_used was
136 * invalid we render the complete report as invalid. Protocol mandate
137 * the DSU be accurate or not reported.
138 */
139 spin_lock(&objlay->lock);
140 if (objlay->delta_space_valid != OBJ_DSU_INVALID) {
141 objlay->delta_space_valid = OBJ_DSU_VALID;
142 objlay->delta_space_used += space_used;
143 }
144 spin_unlock(&objlay->lock);
145}
146
122extern void objlayout_read_done(struct objlayout_io_state *state, 147extern void objlayout_read_done(struct objlayout_io_state *state,
123 ssize_t status, bool sync); 148 ssize_t status, bool sync);
124extern void objlayout_write_done(struct objlayout_io_state *state, 149extern void objlayout_write_done(struct objlayout_io_state *state,
@@ -149,6 +174,11 @@ extern enum pnfs_try_status objlayout_write_pagelist(
149 struct nfs_write_data *, 174 struct nfs_write_data *,
150 int how); 175 int how);
151 176
177extern void objlayout_encode_layoutcommit(
178 struct pnfs_layout_hdr *,
179 struct xdr_stream *,
180 const struct nfs4_layoutcommit_args *);
181
152extern void objlayout_encode_layoutreturn( 182extern void objlayout_encode_layoutreturn(
153 struct pnfs_layout_hdr *, 183 struct pnfs_layout_hdr *,
154 struct xdr_stream *, 184 struct xdr_stream *,