commit b430b53a138cfdfe0d7ea8625626a634bec99d4f
Author: Arkadiusz Miśkiewicz <[email protected]>
Date:   Mon Oct 29 14:32:25 2018 +0100

    - rel 3; misc fixes from upstream (to be dropped when merged; merged 
possibly in different form)

 misc.patch    | 241 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 xfsprogs.spec |   4 +-
 2 files changed, 244 insertions(+), 1 deletion(-)
---
diff --git a/xfsprogs.spec b/xfsprogs.spec
index 5e5b7e3..2b0e887 100644
--- a/xfsprogs.spec
+++ b/xfsprogs.spec
@@ -4,7 +4,7 @@ Summary:        Tools for the XFS filesystem
 Summary(pl.UTF-8):     Narzędzia do systemu plików XFS
 Name:          xfsprogs
 Version:       4.18.0
-Release:       2
+Release:       3
 License:       LGPL v2.1 (libhandle), GPL v2 (the rest)
 Group:         Applications/System
 Source0:       
https://kernel.org/pub/linux/utils/fs/xfs/xfsprogs/%{name}-%{version}.tar.gz
@@ -12,6 +12,7 @@ Source0:      
https://kernel.org/pub/linux/utils/fs/xfs/xfsprogs/%{name}-%{version}.t
 Source1:       xfs_lsprojid
 Patch0:                %{name}-miscfix-v2.patch
 Patch1:                %{name}-pl.po-update.patch
+Patch2:                misc.patch
 URL:           http://www.xfs.org/
 BuildRequires: autoconf >= 2.50
 BuildRequires: automake
@@ -105,6 +106,7 @@ Biblioteki statyczne do XFS.
 %setup -q
 %patch0 -p1
 %patch1 -p1
+%patch2 -p1
 
 %{__sed} -i -e '1s,/usr/bin/env python3,%{__python3},' scrub/xfs_scrub_all.in 
tools/xfsbuflock.py
 
diff --git a/misc.patch b/misc.patch
new file mode 100644
index 0000000..14aa86a
--- /dev/null
+++ b/misc.patch
@@ -0,0 +1,241 @@
+From: Darrick J. Wong <[email protected]>
+
+When we added a new defer op type for agfl block freeing to the kernel,
+we forgot to add that type to the userspace side of things.  This will
+cause spontaneous combustion in xfs_repair if we try to rebuild
+directories.
+
+Fixes: d5c1b462232 ("xfs: defer agfl block frees when dfops is available")
+Signed-off-by: Darrick J. Wong <[email protected]>
+---
+ libxfs/defer_item.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 44 insertions(+)
+
+diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c
+index b7185c1a..82aa32a8 100644
+--- a/libxfs/defer_item.c
++++ b/libxfs/defer_item.c
+@@ -118,11 +118,55 @@ static const struct xfs_defer_op_type 
xfs_extent_free_defer_type = {
+       .cancel_item    = xfs_extent_free_cancel_item,
+ };
+ 
++/*
++ * AGFL blocks are accounted differently in the reserve pools and are not
++ * inserted into the busy extent list.
++ */
++STATIC int
++xfs_agfl_free_finish_item(
++      struct xfs_trans                *tp,
++      struct list_head                *item,
++      void                            *done_item,
++      void                            **state)
++{
++      struct xfs_mount                *mp = tp->t_mountp;
++      struct xfs_extent_free_item     *free;
++      struct xfs_buf                  *agbp;
++      int                             error;
++      xfs_agnumber_t                  agno;
++      xfs_agblock_t                   agbno;
++
++      free = container_of(item, struct xfs_extent_free_item, xefi_list);
++      ASSERT(free->xefi_blockcount == 1);
++      agno = XFS_FSB_TO_AGNO(mp, free->xefi_startblock);
++      agbno = XFS_FSB_TO_AGBNO(mp, free->xefi_startblock);
++
++      error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
++      if (!error)
++              error = xfs_free_agfl_block(tp, agno, agbno, agbp,
++                                          &free->xefi_oinfo);
++      kmem_free(free);
++      return error;
++}
++
++/* sub-type with special handling for AGFL deferred frees */
++static const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
++      .type           = XFS_DEFER_OPS_TYPE_AGFL_FREE,
++      .diff_items     = xfs_extent_free_diff_items,
++      .create_intent  = xfs_extent_free_create_intent,
++      .abort_intent   = xfs_extent_free_abort_intent,
++      .log_item       = xfs_extent_free_log_item,
++      .create_done    = xfs_extent_free_create_done,
++      .finish_item    = xfs_agfl_free_finish_item,
++      .cancel_item    = xfs_extent_free_cancel_item,
++};
++
+ /* Register the deferred op type. */
+ void
+ xfs_extent_free_init_defer_op(void)
+ {
+       xfs_defer_init_op_type(&xfs_extent_free_defer_type);
++      xfs_defer_init_op_type(&xfs_agfl_free_defer_type);
+ }
+ 
+ /* Reverse Mapping */
+Subject: [PATCH 1/2] xfs_repair: initialize realloced bplist in
+ longform_dir2_entry_check
+From:   Eric Sandeen <[email protected]>
+
+If we need to realloc the bplist[] array holding buffers for a given
+directory, we don't initialize the new slots.  This causes a problem
+if the directory has holes, because those slots never get filled in.
+
+At the end of the function we call libxfs_putbuf for every non-null
+slot, and any uninitialized slots are segfault landmines.
+
+Make sure we initialize all new slots to NULL for this reason.
+
+Reported-by: Oleg Davydov <[email protected]>
+Signed-off-by: Eric Sandeen <[email protected]>
+---
+
+diff --git a/repair/phase6.c b/repair/phase6.c
+index b87c751..9d24a4f 100644
+--- a/repair/phase6.c
++++ b/repair/phase6.c
+@@ -2348,6 +2348,8 @@ longform_dir2_entry_check(xfs_mount_t    *mp,
+ 
+               db = xfs_dir2_da_to_db(mp->m_dir_geo, da_bno);
+               if (db >= num_bps) {
++                      int last_size = num_bps;
++
+                       /* more data blocks than expected */
+                       num_bps = db + 1;
+                       bplist = realloc(bplist, num_bps * sizeof(struct 
xfs_buf*));
+@@ -2355,6 +2357,9 @@ longform_dir2_entry_check(xfs_mount_t    *mp,
+                               do_error(_("realloc failed in %s (%zu 
bytes)\n"),
+                                       __func__,
+                                       num_bps * sizeof(struct xfs_buf*));
++                      /* Initialize the new elements */
++                      for (i = last_size; i < num_bps; i++)
++                              bplist[i] = NULL;
+               }
+ 
+               if (isblock)
+
+Subject: [PATCH 2/2] xfs_repair: continue after xfs_bunmapi deadlock avoidance
+From:   Eric Sandeen <[email protected]>
+
+After commit:
+
+15a8bcc xfs: fix multi-AG deadlock in xfs_bunmapi
+
+xfs_bunmapi can legitimately return before all work is done.
+Sadly nobody told xfs_repair, so it fires an assert:
+
+ phase6.c:1410: longform_dir2_rebuild: Assertion `done' failed. 
+
+Fix this by calling back in until all work is done, as we do
+in the kernel.
+
+Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1641116
+Reported-by: Tomasz Torcz <[email protected]>
+Signed-off-by: Eric Sandeen <[email protected]>
+---
+
+diff --git a/repair/phase6.c b/repair/phase6.c
+index e017326..b87c751 100644
+--- a/repair/phase6.c
++++ b/repair/phase6.c
+@@ -1317,7 +1317,7 @@ longform_dir2_rebuild(
+       xfs_fileoff_t           lastblock;
+       xfs_inode_t             pip;
+       dir_hash_ent_t          *p;
+-      int                     done;
++      int                     done = 0;
+ 
+       /*
+        * trash directory completely and rebuild from scratch using the
+@@ -1352,12 +1352,25 @@ longform_dir2_rebuild(
+                       error);
+ 
+       /* free all data, leaf, node and freespace blocks */
+-      error = -libxfs_bunmapi(tp, ip, 0, lastblock, XFS_BMAPI_METADATA, 0,
+-                              &firstblock, &dfops, &done);
+-      if (error) {
+-              do_warn(_("xfs_bunmapi failed -- error - %d\n"), error);
+-              goto out_bmap_cancel;
+-      }
++      while (!done) {
++             error = -libxfs_bunmapi(tp, ip, 0, lastblock, XFS_BMAPI_METADATA,
++                                     0, &firstblock, &dfops, &done);
++             if (error) {
++                     do_warn(_("xfs_bunmapi failed -- error - %d\n"), error);
++                     goto out_bmap_cancel;
++             }
++             error = xfs_defer_finish(&tp, &dfops);
++             if (error) {
++                     do_warn(("defer_finish failed -- error - %d\n"), error);
++                     goto out_bmap_cancel;
++             }
++             /*
++              * Close out trans and start the next one in the chain.
++              */
++             error = xfs_trans_roll_inode(&tp, ip);
++             if (error)
++                      goto out_bmap_cancel;
++        }
+ 
+       ASSERT(done);
+ 
+
+From:   "Darrick J. Wong" <[email protected]>
+Subject: [PATCH] libxfs: check all defer ops types
+
+From: Darrick J. Wong <[email protected]>
+
+Make sure we have all the defer ops types loaded before proceeding.
+
+Signed-off-by: Darrick J. Wong <[email protected]>
+---
+ libxfs/init.c      |    5 +++++
+ libxfs/xfs_defer.c |   12 ++++++++++++
+ libxfs/xfs_defer.h |    1 +
+ 3 files changed, 18 insertions(+)
+
+diff --git a/libxfs/init.c b/libxfs/init.c
+index 750b8f20..d1fdc3a8 100644
+--- a/libxfs/init.c
++++ b/libxfs/init.c
+@@ -253,6 +253,11 @@ libxfs_init(libxfs_init_t *a)
+       xfs_rmap_update_init_defer_op();
+       xfs_refcount_update_init_defer_op();
+       xfs_bmap_update_init_defer_op();
++      if (!xfs_defer_check_all_present()) {
++              fprintf(stderr, _("%s: defer ops not all there\n"),
++                      progname);
++              goto done;
++      }
+ 
+       radix_tree_init();
+ 
+diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c
+index 5a6da0f3..cd3a8ef3 100644
+--- a/libxfs/xfs_defer.c
++++ b/libxfs/xfs_defer.c
+@@ -545,3 +545,15 @@ xfs_defer_move(
+ 
+       xfs_defer_reset(stp);
+ }
++
++/* Make sure we filled out all the defer_ops types. */
++bool
++xfs_defer_check_all_present(void)
++{
++      int             x;
++
++      for(x = 0; x < XFS_DEFER_OPS_TYPE_MAX; x++)
++              if (defer_op_types[x] == NULL)
++                      return false;
++      return true;
++}
+diff --git a/libxfs/xfs_defer.h b/libxfs/xfs_defer.h
+index 2584a5b9..bc7ae7ff 100644
+--- a/libxfs/xfs_defer.h
++++ b/libxfs/xfs_defer.h
+@@ -57,5 +57,6 @@ struct xfs_defer_op_type {
+ };
+ 
+ void xfs_defer_init_op_type(const struct xfs_defer_op_type *type);
++bool xfs_defer_check_all_present(void);
+ 
+ #endif /* __XFS_DEFER_H__ */
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/xfsprogs.git/commitdiff/b430b53a138cfdfe0d7ea8625626a634bec99d4f

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to