diff options
| -rw-r--r-- | fs/nfs/objlayout/objio_osd.c | 1 | ||||
| -rw-r--r-- | fs/nfs/objlayout/objlayout.c | 30 | ||||
| -rw-r--r-- | fs/nfs/objlayout/objlayout.h | 30 |
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 | ||
| 437 | void | ||
| 438 | objlayout_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 | |||
| 436 | static int | 466 | static int |
| 437 | err_prio(u32 oer_errno) | 467 | err_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 @@ | |||
| 51 | struct objlayout { | 51 | struct 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 | ||
| 130 | static inline void | ||
| 131 | objlayout_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 | |||
| 122 | extern void objlayout_read_done(struct objlayout_io_state *state, | 147 | extern void objlayout_read_done(struct objlayout_io_state *state, |
| 123 | ssize_t status, bool sync); | 148 | ssize_t status, bool sync); |
| 124 | extern void objlayout_write_done(struct objlayout_io_state *state, | 149 | extern 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 | ||
| 177 | extern void objlayout_encode_layoutcommit( | ||
| 178 | struct pnfs_layout_hdr *, | ||
| 179 | struct xdr_stream *, | ||
| 180 | const struct nfs4_layoutcommit_args *); | ||
| 181 | |||
| 152 | extern void objlayout_encode_layoutreturn( | 182 | extern void objlayout_encode_layoutreturn( |
| 153 | struct pnfs_layout_hdr *, | 183 | struct pnfs_layout_hdr *, |
| 154 | struct xdr_stream *, | 184 | struct xdr_stream *, |
