xfs
[Top] [All Lists]

[PATCH 27/32] libxfs: fix root inode handling inconsistencies

To: xfs@xxxxxxxxxxx
Subject: [PATCH 27/32] libxfs: fix root inode handling inconsistencies
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Mon, 30 Sep 2013 13:15:39 +1000
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1380510944-8571-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1380510944-8571-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

When "mounting" a filesystem via libxfs_mount(), callers can tell
libxfs to read the root and realtime inodes into cache. However,
when unmounting the filesystem, libxfs_unmount() used to
unconditionally free root inodes if they were present.

This leads to interesting issues like in mkfs, when it handles
creation, reading and freeing of the root and rt inodes itself.
It, however, passes in the flag to tell libxfs_mount() to read the
root inode, and so when unmounting throws an error like:

cache_node_put: node put on refcount 0 (node=0x684610)

When a second libxfs_iput() call is made on the root inode.

Clean this up and fix up all the callers that use magic numbers
rather than symbolic values to tell libxfs tomount the root inodes.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 copy/xfs_copy.c | 3 ++-
 mkfs/xfs_mkfs.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index bb37279..b6695d7 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -684,7 +684,8 @@ main(int argc, char **argv)
        sb = &mbuf.m_sb;
        libxfs_sb_from_disk(sb, XFS_BUF_TO_SBP(sbp));
 
-       mp = libxfs_mount(&mbuf, sb, xargs.ddev, xargs.logdev, xargs.rtdev, 1);
+       mp = libxfs_mount(&mbuf, sb, xargs.ddev, xargs.logdev, xargs.rtdev,
+                         LIBXFS_MOUNT_ROOTINOS);
        if (mp == NULL) {
                do_log(_("%s: %s filesystem failed to initialize\n"
                        "%s: Aborting.\n"), progname, source_name, progname);
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index eafbed3..60e4d88 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2556,6 +2556,7 @@ _("size %s specified for log subvolume is too large, 
maximum is %lld blocks\n"),
        memset(XFS_BUF_PTR(buf), 0, sectorsize);
        libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp, XFS_SB_ALL_BITS);
        libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+       libxfs_purgebuf(buf);
 
        /*
         * If the data area is a file, then grow it out to its final size
@@ -2590,7 +2591,7 @@ _("size %s specified for log subvolume is too large, 
maximum is %lld blocks\n"),
                (xfs_extlen_t)XFS_FSB_TO_BB(mp, logblocks),
                &sbp->sb_uuid, logversion, lsunit, XLOG_FMT);
 
-       mp = libxfs_mount(mp, sbp, xi.ddev, xi.logdev, xi.rtdev, 1);
+       mp = libxfs_mount(mp, sbp, xi.ddev, xi.logdev, xi.rtdev, 0);
        if (mp == NULL) {
                fprintf(stderr, _("%s: filesystem failed to initialize\n"),
                        progname);
-- 
1.8.3.2

<Prev in Thread] Current Thread [Next in Thread>