@@ -653,6 +653,7 @@ bl_encode_layoutcommit(struct pnfs_layout_type *lo, struct xdr_stream *xdr,
const struct pnfs_layoutcommit_arg *arg)
{
dprintk("%s enter\n", __func__);
+ encode_pnfs_block_layoutupdate(BLK_LO2EXT(lo), xdr, arg);
}
static void
@@ -263,6 +263,9 @@ void put_extent(struct pnfs_block_extent *be);
struct pnfs_block_extent *alloc_extent(void);
struct pnfs_block_extent *get_extent(struct pnfs_block_extent *be);
int is_sector_initialized(struct pnfs_inval_markings *marks, sector_t isect);
+int encode_pnfs_block_layoutupdate(struct pnfs_block_layout *bl,
+ struct xdr_stream *xdr,
+ const struct pnfs_layoutcommit_arg *arg);
int add_and_merge_extent(struct pnfs_block_layout *bl,
struct pnfs_block_extent *new);
int mark_for_commit(struct pnfs_block_extent *be,
@@ -680,3 +680,51 @@ find_get_extent(struct pnfs_block_layout *bl, sector_t isect,
print_bl_extent(ret);
return ret;
}
+
+int
+encode_pnfs_block_layoutupdate(struct pnfs_block_layout *bl,
+ struct xdr_stream *xdr,
+ const struct pnfs_layoutcommit_arg *arg)
+{
+ sector_t start, end;
+ struct pnfs_block_short_extent *lce, *save;
+ unsigned int count;
+ struct bl_layoutupdate_data *bld = arg->layoutdriver_data;
+ struct list_head *ranges = &bld->ranges;
+ __be32 *p, *xdr_start;
+
+ dprintk("%s enter\n", __func__);
+ start = arg->lseg.offset >> 9;
+ end = start + (arg->lseg.length >> 9);
+ dprintk("%s set start=%llu, end=%llu\n",
+ __func__, (u64)start, (u64)end);
+
+ /* BUG - creation of bl_commit is buggy - need to wait for
+ * entire block to be marked WRITTEN before it can be added.
+ */
+ spin_lock(&bl->bl_ext_lock);
+ list_splice_init(&bl->bl_commit, ranges);
+ count = bl->bl_count;
+ bl->bl_count = 0;
+ /* Want to adjust for possible truncate */
+ /* We now want to adjust argument range */
+ spin_unlock(&bl->bl_ext_lock);
+
+ dprintk("%s found %i ranges\n", __func__, count);
+ /* XDR encode the ranges found */
+ xdr_start = p = xdr_reserve_space(xdr, 8);
+ p++;
+ WRITE32(count);
+ list_for_each_entry_safe(lce, save, ranges, bse_node) {
+ p = xdr_reserve_space(xdr, 7 * 4 + sizeof(lce->bse_devid.data));
+
+ WRITE_DEVID(&lce->bse_devid);
+ WRITE64(lce->bse_f_offset << 9);
+ WRITE64(lce->bse_length << 9);
+ WRITE64(0LL);
+ WRITE32(PNFS_BLOCK_READWRITE_DATA);
+ }
+
+ *xdr_start = cpu_to_be32((xdr->p - xdr_start - 1) * 4);
+ return 0;
+}