]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: plumb in bmap deferred op log items
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 25 Oct 2016 22:14:31 +0000 (15:14 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 26 Oct 2016 18:13:49 +0000 (11:13 -0700)
Add a deferred op handler for block mapping actions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
include/xfs_trans.h
libxfs/defer_item.c
libxfs/init.c

index 739a792f9bbcacf35dd270a9cee5235f3872ce7a..44deebb05fe13362215a395fcb705aa9e5add1c6 100644 (file)
@@ -148,5 +148,6 @@ libxfs_trans_read_buf(
 void xfs_extent_free_init_defer_op(void);
 void xfs_rmap_update_init_defer_op(void);
 void xfs_refcount_update_init_defer_op(void);
+void xfs_bmap_update_init_defer_op(void);
 
 #endif /* __XFS_TRANS_H__ */
index 1b7d037b9b5d1a6b692f0a272edb888135864899..49bf7f8bdde31518814b2331ae25ed197d40903d 100644 (file)
@@ -32,6 +32,8 @@
 #include "xfs_alloc.h"
 #include "xfs_rmap.h"
 #include "xfs_refcount.h"
+#include "xfs_bmap.h"
+#include "xfs_inode.h"
 
 /* Dummy defer item ops, since we don't do logging. */
 
@@ -387,3 +389,108 @@ xfs_refcount_update_init_defer_op(void)
 {
        xfs_defer_init_op_type(&xfs_refcount_update_defer_type);
 }
+
+/* Inode Block Mapping */
+
+/* Sort bmap intents by inode. */
+static int
+xfs_bmap_update_diff_items(
+       void                            *priv,
+       struct list_head                *a,
+       struct list_head                *b)
+{
+       struct xfs_bmap_intent          *ba;
+       struct xfs_bmap_intent          *bb;
+
+       ba = container_of(a, struct xfs_bmap_intent, bi_list);
+       bb = container_of(b, struct xfs_bmap_intent, bi_list);
+       return ba->bi_owner->i_ino - bb->bi_owner->i_ino;
+}
+
+/* Get an BUI. */
+STATIC void *
+xfs_bmap_update_create_intent(
+       struct xfs_trans                *tp,
+       unsigned int                    count)
+{
+       return NULL;
+}
+
+/* Log bmap updates in the intent item. */
+STATIC void
+xfs_bmap_update_log_item(
+       struct xfs_trans                *tp,
+       void                            *intent,
+       struct list_head                *item)
+{
+}
+
+/* Get an BUD so we can process all the deferred rmap updates. */
+STATIC void *
+xfs_bmap_update_create_done(
+       struct xfs_trans                *tp,
+       void                            *intent,
+       unsigned int                    count)
+{
+       return NULL;
+}
+
+/* Process a deferred rmap update. */
+STATIC int
+xfs_bmap_update_finish_item(
+       struct xfs_trans                *tp,
+       struct xfs_defer_ops            *dop,
+       struct list_head                *item,
+       void                            *done_item,
+       void                            **state)
+{
+       struct xfs_bmap_intent          *bmap;
+       int                             error;
+
+       bmap = container_of(item, struct xfs_bmap_intent, bi_list);
+       error = xfs_bmap_finish_one(tp, dop,
+                       bmap->bi_owner,
+                       bmap->bi_type, bmap->bi_whichfork,
+                       bmap->bi_bmap.br_startoff,
+                       bmap->bi_bmap.br_startblock,
+                       bmap->bi_bmap.br_blockcount,
+                       bmap->bi_bmap.br_state);
+       kmem_free(bmap);
+       return error;
+}
+
+/* Abort all pending BUIs. */
+STATIC void
+xfs_bmap_update_abort_intent(
+       void                            *intent)
+{
+}
+
+/* Cancel a deferred rmap update. */
+STATIC void
+xfs_bmap_update_cancel_item(
+       struct list_head                *item)
+{
+       struct xfs_bmap_intent          *bmap;
+
+       bmap = container_of(item, struct xfs_bmap_intent, bi_list);
+       kmem_free(bmap);
+}
+
+static const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
+       .type           = XFS_DEFER_OPS_TYPE_BMAP,
+       .diff_items     = xfs_bmap_update_diff_items,
+       .create_intent  = xfs_bmap_update_create_intent,
+       .abort_intent   = xfs_bmap_update_abort_intent,
+       .log_item       = xfs_bmap_update_log_item,
+       .create_done    = xfs_bmap_update_create_done,
+       .finish_item    = xfs_bmap_update_finish_item,
+       .cancel_item    = xfs_bmap_update_cancel_item,
+};
+
+/* Register the deferred op type. */
+void
+xfs_bmap_update_init_defer_op(void)
+{
+       xfs_defer_init_op_type(&xfs_bmap_update_defer_type);
+}
index 9d9e9287f0683612d1e8a85275385a6d4bfb27ad..372158935940be5c2fad24f6d387d5327e8ef833 100644 (file)
@@ -269,6 +269,7 @@ libxfs_init(libxfs_init_t *a)
        xfs_extent_free_init_defer_op();
        xfs_rmap_update_init_defer_op();
        xfs_refcount_update_init_defer_op();
+       xfs_bmap_update_init_defer_op();
 
        radix_tree_init();