From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: david@fromorbit.com, darrick.wong@oracle.com
Cc: linux-fsdevel@vger.kernel.org, vishal.l.verma@intel.com,
bfoster@redhat.com, xfs@oss.sgi.com
Subject: [PATCH 40/47] xfs: enable the xfs_defer mechanism to process rmaps to update
Date: Wed, 20 Jul 2016 22:00:29 -0700 [thread overview]
Message-ID: <146907722925.25461.2811549111055669475.stgit@birch.djwong.org> (raw)
In-Reply-To: <146907695530.25461.3225785294902719773.stgit@birch.djwong.org>
Connect the xfs_defer mechanism with the pieces that we'll need to
handle deferred rmap updates. We'll wire up the existing code to
our new deferred mechanism later.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/libxfs/xfs_defer.h | 1
fs/xfs/xfs_super.c | 1
fs/xfs/xfs_trans.h | 11 +---
fs/xfs/xfs_trans_rmap.c | 131 ++++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 134 insertions(+), 10 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h
index b9b5a92..cc3981c 100644
--- a/fs/xfs/libxfs/xfs_defer.h
+++ b/fs/xfs/libxfs/xfs_defer.h
@@ -51,6 +51,7 @@ struct xfs_defer_pending {
* find all the space it needs.
*/
enum xfs_defer_ops_type {
+ XFS_DEFER_OPS_TYPE_RMAP,
XFS_DEFER_OPS_TYPE_FREE,
XFS_DEFER_OPS_TYPE_MAX,
};
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 5c28072..b8d4473 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1880,6 +1880,7 @@ init_xfs_fs(void)
XFS_BUILD_OPTIONS " enabled\n");
xfs_extent_free_init_defer_op();
+ xfs_rmap_update_init_defer_op();
xfs_dir_startup();
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index fd2dfc0..e9e5766 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -33,6 +33,8 @@ struct xfs_trans;
struct xfs_trans_res;
struct xfs_dquot_acct;
struct xfs_busy_extent;
+struct xfs_rud_log_item;
+struct xfs_rui_log_item;
typedef struct xfs_log_item {
struct list_head li_ail; /* AIL pointers */
@@ -232,15 +234,10 @@ void xfs_trans_buf_copy_type(struct xfs_buf *dst_bp,
extern kmem_zone_t *xfs_trans_zone;
extern kmem_zone_t *xfs_log_item_desc_zone;
+/* rmap updates */
enum xfs_rmap_intent_type;
-struct xfs_rui_log_item *xfs_trans_get_rui(struct xfs_trans *tp, uint nextents);
-void xfs_trans_log_start_rmap_update(struct xfs_trans *tp,
- struct xfs_rui_log_item *ruip, enum xfs_rmap_intent_type type,
- __uint64_t owner, int whichfork, xfs_fileoff_t startoff,
- xfs_fsblock_t startblock, xfs_filblks_t blockcount,
- xfs_exntst_t state);
-
+void xfs_rmap_update_init_defer_op(void);
struct xfs_rud_log_item *xfs_trans_get_rud(struct xfs_trans *tp,
struct xfs_rui_log_item *ruip, uint nextents);
int xfs_trans_log_finish_rmap_update(struct xfs_trans *tp,
diff --git a/fs/xfs/xfs_trans_rmap.c b/fs/xfs/xfs_trans_rmap.c
index e3a5172..baab990 100644
--- a/fs/xfs/xfs_trans_rmap.c
+++ b/fs/xfs/xfs_trans_rmap.c
@@ -37,7 +37,7 @@
* caller must use all nextents extents, because we are not
* flexible about this at all.
*/
-struct xfs_rui_log_item *
+STATIC struct xfs_rui_log_item *
xfs_trans_get_rui(
struct xfs_trans *tp,
uint nextents)
@@ -96,7 +96,7 @@ xfs_trans_set_rmap_flags(
* mapping is to be logged as needing to be updated. It should be
* called once for each mapping.
*/
-void
+STATIC void
xfs_trans_log_start_rmap_update(
struct xfs_trans *tp,
struct xfs_rui_log_item *ruip,
@@ -129,7 +129,6 @@ xfs_trans_log_start_rmap_update(
xfs_trans_set_rmap_flags(rmap, type, whichfork, state);
}
-
/*
* This routine is called to allocate an "rmap update done"
* log item that will hold nextents worth of extents. The
@@ -203,3 +202,129 @@ xfs_trans_log_finish_rmap_update(
return error;
}
+
+/* Sort rmap intents by AG. */
+static int
+xfs_rmap_update_diff_items(
+ void *priv,
+ struct list_head *a,
+ struct list_head *b)
+{
+ struct xfs_mount *mp = priv;
+ struct xfs_rmap_intent *ra;
+ struct xfs_rmap_intent *rb;
+
+ ra = container_of(a, struct xfs_rmap_intent, ri_list);
+ rb = container_of(b, struct xfs_rmap_intent, ri_list);
+ return XFS_FSB_TO_AGNO(mp, ra->ri_bmap.br_startblock) -
+ XFS_FSB_TO_AGNO(mp, rb->ri_bmap.br_startblock);
+}
+
+/* Get an RUI. */
+STATIC void *
+xfs_rmap_update_create_intent(
+ struct xfs_trans *tp,
+ unsigned int count)
+{
+ return xfs_trans_get_rui(tp, count);
+}
+
+/* Log rmap updates in the intent item. */
+STATIC void
+xfs_rmap_update_log_item(
+ struct xfs_trans *tp,
+ void *intent,
+ struct list_head *item)
+{
+ struct xfs_rmap_intent *rmap;
+
+ rmap = container_of(item, struct xfs_rmap_intent, ri_list);
+ xfs_trans_log_start_rmap_update(tp, intent, rmap->ri_type,
+ rmap->ri_owner, rmap->ri_whichfork,
+ rmap->ri_bmap.br_startoff,
+ rmap->ri_bmap.br_startblock,
+ rmap->ri_bmap.br_blockcount,
+ rmap->ri_bmap.br_state);
+}
+
+/* Get an RUD so we can process all the deferred rmap updates. */
+STATIC void *
+xfs_rmap_update_create_done(
+ struct xfs_trans *tp,
+ void *intent,
+ unsigned int count)
+{
+ return xfs_trans_get_rud(tp, intent, count);
+}
+
+/* Process a deferred rmap update. */
+STATIC int
+xfs_rmap_update_finish_item(
+ struct xfs_trans *tp,
+ struct xfs_defer_ops *dop,
+ struct list_head *item,
+ void *done_item,
+ void **state)
+{
+ struct xfs_rmap_intent *rmap;
+ int error;
+
+ rmap = container_of(item, struct xfs_rmap_intent, ri_list);
+ error = xfs_trans_log_finish_rmap_update(tp, done_item,
+ rmap->ri_type,
+ rmap->ri_owner, rmap->ri_whichfork,
+ rmap->ri_bmap.br_startoff,
+ rmap->ri_bmap.br_startblock,
+ rmap->ri_bmap.br_blockcount,
+ rmap->ri_bmap.br_state);
+ kmem_free(rmap);
+ return error;
+}
+
+/* Clean up after processing deferred rmaps. */
+STATIC void
+xfs_rmap_update_finish_cleanup(
+ struct xfs_trans *tp,
+ void *state,
+ int error)
+{
+}
+
+/* Abort all pending RUIs. */
+STATIC void
+xfs_rmap_update_abort_intent(
+ void *intent)
+{
+ xfs_rui_release(intent);
+}
+
+/* Cancel a deferred rmap update. */
+STATIC void
+xfs_rmap_update_cancel_item(
+ struct list_head *item)
+{
+ struct xfs_rmap_intent *rmap;
+
+ rmap = container_of(item, struct xfs_rmap_intent, ri_list);
+ kmem_free(rmap);
+}
+
+static const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
+ .type = XFS_DEFER_OPS_TYPE_RMAP,
+ .max_items = XFS_RUI_MAX_FAST_EXTENTS,
+ .diff_items = xfs_rmap_update_diff_items,
+ .create_intent = xfs_rmap_update_create_intent,
+ .abort_intent = xfs_rmap_update_abort_intent,
+ .log_item = xfs_rmap_update_log_item,
+ .create_done = xfs_rmap_update_create_done,
+ .finish_item = xfs_rmap_update_finish_item,
+ .finish_cleanup = xfs_rmap_update_finish_cleanup,
+ .cancel_item = xfs_rmap_update_cancel_item,
+};
+
+/* Register the deferred op type. */
+void
+xfs_rmap_update_init_defer_op(void)
+{
+ xfs_defer_init_op_type(&xfs_rmap_update_defer_type);
+}
next prev parent reply other threads:[~2016-07-21 5:00 UTC|newest]
Thread overview: 121+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-21 4:55 [PATCH v7 00/47] xfs: add reverse mapping support Darrick J. Wong
2016-07-21 4:56 ` [PATCH 01/47] vfs: fix return type of ioctl_file_dedupe_range Darrick J. Wong
2016-08-01 6:33 ` Christoph Hellwig
2016-07-21 4:56 ` [PATCH 02/47] vfs: support FS_XFLAG_REFLINK and FS_XFLAG_COWEXTSIZE Darrick J. Wong
2016-08-01 6:33 ` Christoph Hellwig
2016-07-21 4:56 ` [PATCH 03/47] xfs: fix attr shortform structure alignment on cris Darrick J. Wong
2016-07-26 16:36 ` Brian Foster
2016-08-01 6:34 ` Christoph Hellwig
2016-07-21 4:56 ` [PATCH 04/47] xfs: fix locking of the rt bitmap/summary inodes Darrick J. Wong
2016-07-26 16:36 ` Brian Foster
2016-07-28 18:58 ` Darrick J. Wong
2016-08-01 6:34 ` Christoph Hellwig
2016-07-21 4:56 ` [PATCH 05/47] xfs: set *stat=1 after iroot realloc Darrick J. Wong
2016-07-26 16:36 ` Brian Foster
2016-08-01 6:35 ` Christoph Hellwig
2016-07-21 4:56 ` [PATCH 06/47] xfs: during btree split, save new block key & ptr for future insertion Darrick J. Wong
2016-07-26 16:36 ` Brian Foster
2016-08-01 6:37 ` Christoph Hellwig
2016-07-21 4:56 ` [PATCH 07/47] xfs: add function pointers for get/update keys to the btree Darrick J. Wong
2016-07-26 19:09 ` Brian Foster
2016-07-28 19:13 ` Darrick J. Wong
2016-07-28 19:46 ` [PATCH v2 " Darrick J. Wong
2016-08-01 15:57 ` Brian Foster
2016-08-01 17:54 ` Darrick J. Wong
2016-08-01 6:39 ` [PATCH " Christoph Hellwig
2016-08-01 17:33 ` Darrick J. Wong
2016-08-02 12:23 ` Christoph Hellwig
2016-08-03 0:12 ` Darrick J. Wong
2016-07-21 4:56 ` [PATCH 08/47] xfs: support btrees with overlapping intervals for keys Darrick J. Wong
2016-08-01 6:48 ` Christoph Hellwig
2016-08-01 19:11 ` Darrick J. Wong
2016-08-02 12:03 ` Christoph Hellwig
2016-08-03 3:29 ` Darrick J. Wong
2016-08-02 14:04 ` Brian Foster
2016-08-03 1:06 ` Dave Chinner
2016-08-01 17:47 ` Brian Foster
2016-08-01 19:18 ` Darrick J. Wong
2016-07-21 4:56 ` [PATCH 09/47] xfs: introduce interval queries on btrees Darrick J. Wong
2016-08-01 8:00 ` Christoph Hellwig
2016-07-21 4:57 ` [PATCH 10/47] xfs: refactor btree owner change into a separate visit-blocks function Darrick J. Wong
2016-08-01 6:50 ` Christoph Hellwig
2016-07-21 4:57 ` [PATCH 11/47] xfs: move deferred operations into a separate file Darrick J. Wong
2016-08-01 7:08 ` Christoph Hellwig
2016-08-01 8:02 ` Christoph Hellwig
2016-08-02 22:39 ` Dave Chinner
2016-08-03 9:16 ` Christoph Hellwig
2016-08-03 22:57 ` Dave Chinner
2016-08-04 16:00 ` Christoph Hellwig
2016-08-04 23:44 ` Dave Chinner
2016-08-02 17:30 ` Brian Foster
2016-07-21 4:57 ` [PATCH 12/47] xfs: add tracepoints for the deferred ops mechanism Darrick J. Wong
2016-07-21 4:57 ` [PATCH 13/47] xfs: clean up typedef usage in the EFI/EFD handling code Darrick J. Wong
2016-08-01 7:09 ` Christoph Hellwig
2016-07-21 4:57 ` [PATCH 14/47] xfs: enable the xfs_defer mechanism to process extents to free Darrick J. Wong
2016-08-01 7:09 ` Christoph Hellwig
2016-08-02 17:30 ` Brian Foster
2016-07-21 4:57 ` [PATCH 15/47] xfs: rework xfs_bmap_free callers to use xfs_defer_ops Darrick J. Wong
2016-08-02 17:30 ` Brian Foster
2016-07-21 4:57 ` [PATCH 16/47] xfs: change xfs_bmap_{finish, cancel, init, free} -> xfs_defer_* Darrick J. Wong
2016-08-02 17:30 ` Brian Foster
2016-08-02 20:47 ` Darrick J. Wong
2016-07-21 4:57 ` [PATCH 17/47] xfs: rename flist/free_list to dfops Darrick J. Wong
2016-08-02 17:30 ` Brian Foster
2016-07-21 4:58 ` [PATCH 18/47] xfs: refactor redo intent item processing Darrick J. Wong
2016-08-01 8:10 ` Christoph Hellwig
2016-08-02 20:35 ` Darrick J. Wong
2016-08-02 18:47 ` Brian Foster
2016-07-21 4:58 ` [PATCH 19/47] xfs: add tracepoints and error injection for deferred extent freeing Darrick J. Wong
2016-08-02 18:48 ` Brian Foster
2016-08-02 20:24 ` Darrick J. Wong
2016-08-02 21:38 ` Brian Foster
2016-08-02 22:43 ` Darrick J. Wong
2016-07-21 4:58 ` [PATCH 20/47] xfs: increase XFS_BTREE_MAXLEVELS to fit the rmapbt Darrick J. Wong
2016-08-02 18:48 ` Brian Foster
2016-08-02 20:06 ` Darrick J. Wong
2016-08-02 21:38 ` Brian Foster
2016-07-21 4:58 ` [PATCH 21/47] xfs: introduce rmap btree definitions Darrick J. Wong
2016-07-21 4:58 ` [PATCH 22/47] xfs: add rmap btree stats infrastructure Darrick J. Wong
2016-07-21 4:58 ` [PATCH 23/47] xfs: rmap btree add more reserved blocks Darrick J. Wong
2016-07-21 4:58 ` [PATCH 24/47] xfs: add owner field to extent allocation and freeing Darrick J. Wong
2016-07-21 4:58 ` [PATCH 25/47] xfs: introduce rmap extent operation stubs Darrick J. Wong
2016-07-21 4:58 ` [PATCH 26/47] xfs: define the on-disk rmap btree format Darrick J. Wong
2016-07-21 4:59 ` [PATCH 27/47] xfs: add rmap btree growfs support Darrick J. Wong
2016-07-21 4:59 ` [PATCH 28/47] xfs: rmap btree transaction reservations Darrick J. Wong
2016-07-21 4:59 ` [PATCH 29/47] xfs: rmap btree requires more reserved free space Darrick J. Wong
2016-07-21 4:59 ` [PATCH 30/47] xfs: add rmap btree operations Darrick J. Wong
2016-07-21 4:59 ` [PATCH 31/47] xfs: support overlapping intervals in the rmap btree Darrick J. Wong
2016-07-21 4:59 ` [PATCH 32/47] xfs: teach rmapbt to support interval queries Darrick J. Wong
2016-07-21 4:59 ` [PATCH 33/47] xfs: add tracepoints for the rmap functions Darrick J. Wong
2016-07-21 4:59 ` [PATCH 34/47] xfs: add an extent to the rmap btree Darrick J. Wong
2016-07-21 4:59 ` [PATCH 35/47] xfs: remove an extent from " Darrick J. Wong
2016-07-21 5:00 ` [PATCH 36/47] xfs: convert unwritten status of reverse mappings Darrick J. Wong
2016-08-03 2:00 ` Dave Chinner
2016-07-21 5:00 ` [PATCH 37/47] xfs: add rmap btree insert and delete helpers Darrick J. Wong
2016-07-21 5:00 ` [PATCH 38/47] xfs: create rmap update intent log items Darrick J. Wong
2016-08-01 7:12 ` Christoph Hellwig
2016-08-01 18:08 ` Darrick J. Wong
2016-07-21 5:00 ` [PATCH 39/47] xfs: log rmap intent items Darrick J. Wong
2016-07-21 5:00 ` Darrick J. Wong [this message]
2016-07-21 5:00 ` [PATCH 41/47] xfs: propagate bmap updates to rmapbt Darrick J. Wong
2016-07-21 5:00 ` [PATCH 42/47] xfs: add rmap btree geometry feature flag Darrick J. Wong
2016-07-21 5:00 ` [PATCH 43/47] xfs: add rmap btree block detection to log recovery Darrick J. Wong
2016-07-21 5:00 ` [PATCH 44/47] xfs: disable XFS_IOC_SWAPEXT when rmap btree is enabled Darrick J. Wong
2016-07-21 5:01 ` [PATCH 45/47] xfs: don't update rmapbt when fixing agfl Darrick J. Wong
2016-07-21 5:01 ` [PATCH 46/47] xfs: enable the rmap btree functionality Darrick J. Wong
2016-07-21 5:01 ` [PATCH 47/47] xfs: introduce the XFS_IOC_GETFSMAP ioctl Darrick J. Wong
2016-07-23 4:28 ` [PATCH v2 " Darrick J. Wong
2016-08-03 19:45 ` [PATCH v7 00/47] xfs: add reverse mapping support Mark Fasheh
2016-08-03 20:55 ` Darrick J. Wong
2016-08-04 0:58 ` Darrick J. Wong
2016-08-04 2:18 ` Mark Fasheh
2016-08-04 15:48 ` Darrick J. Wong
2016-08-04 23:50 ` Dave Chinner
2016-08-05 0:49 ` Darrick J. Wong
2016-08-05 7:01 ` Artem Bityutskiy
2016-08-05 7:22 ` Darrick J. Wong
2016-08-05 10:49 ` Dave Chinner
2016-08-05 11:57 ` Artem Bityutskiy
2016-08-05 22:26 ` Dave Chinner
2016-08-05 18:36 ` Mark Fasheh
2016-08-05 22:39 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=146907722925.25461.2811549111055669475.stgit@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=bfoster@redhat.com \
--cc=david@fromorbit.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=vishal.l.verma@intel.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).