xfs: hoist xfs_fs_geometry to libxfs
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Jan 2018 18:51:27 +0000 (10:51 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Jan 2018 18:54:48 +0000 (10:54 -0800)
Move xfs_fs_geometry to libxfs so that we can clean up the fs geometry
reporting in xfsprogs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
fs/xfs/libxfs/xfs_sb.c
fs/xfs/libxfs/xfs_sb.h
fs/xfs/xfs_fsops.c
fs/xfs/xfs_fsops.h
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_ioctl32.c

index 63e0331b1d2480524b1670067862ed7ccd1a440e..139517ae7aa896498c5e097a5b74be5f396ea89f 100644 (file)
@@ -40,6 +40,8 @@
 #include "xfs_rmap_btree.h"
 #include "xfs_bmap.h"
 #include "xfs_refcount_btree.h"
+#include "xfs_da_format.h"
+#include "xfs_da_btree.h"
 
 /*
  * Physical superblock buffer manipulations. Shared with libxfs in userspace.
@@ -874,3 +876,80 @@ xfs_sync_sb(
                xfs_trans_set_sync(tp);
        return xfs_trans_commit(tp);
 }
+
+int
+xfs_fs_geometry(
+       xfs_mount_t             *mp,
+       xfs_fsop_geom_t         *geo,
+       int                     new_version)
+{
+
+       memset(geo, 0, sizeof(*geo));
+
+       geo->blocksize = mp->m_sb.sb_blocksize;
+       geo->rtextsize = mp->m_sb.sb_rextsize;
+       geo->agblocks = mp->m_sb.sb_agblocks;
+       geo->agcount = mp->m_sb.sb_agcount;
+       geo->logblocks = mp->m_sb.sb_logblocks;
+       geo->sectsize = mp->m_sb.sb_sectsize;
+       geo->inodesize = mp->m_sb.sb_inodesize;
+       geo->imaxpct = mp->m_sb.sb_imax_pct;
+       geo->datablocks = mp->m_sb.sb_dblocks;
+       geo->rtblocks = mp->m_sb.sb_rblocks;
+       geo->rtextents = mp->m_sb.sb_rextents;
+       geo->logstart = mp->m_sb.sb_logstart;
+       ASSERT(sizeof(geo->uuid) == sizeof(mp->m_sb.sb_uuid));
+       memcpy(geo->uuid, &mp->m_sb.sb_uuid, sizeof(mp->m_sb.sb_uuid));
+       if (new_version >= 2) {
+               geo->sunit = mp->m_sb.sb_unit;
+               geo->swidth = mp->m_sb.sb_width;
+       }
+       if (new_version >= 3) {
+               geo->version = XFS_FSOP_GEOM_VERSION;
+               geo->flags = XFS_FSOP_GEOM_FLAGS_NLINK |
+                            XFS_FSOP_GEOM_FLAGS_DIRV2 |
+                       (xfs_sb_version_hasattr(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_ATTR : 0) |
+                       (xfs_sb_version_hasquota(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_QUOTA : 0) |
+                       (xfs_sb_version_hasalign(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_IALIGN : 0) |
+                       (xfs_sb_version_hasdalign(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_DALIGN : 0) |
+                       (xfs_sb_version_hasextflgbit(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_EXTFLG : 0) |
+                       (xfs_sb_version_hassector(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_SECTOR : 0) |
+                       (xfs_sb_version_hasasciici(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_DIRV2CI : 0) |
+                       (xfs_sb_version_haslazysbcount(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_LAZYSB : 0) |
+                       (xfs_sb_version_hasattr2(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_ATTR2 : 0) |
+                       (xfs_sb_version_hasprojid32bit(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_PROJID32 : 0) |
+                       (xfs_sb_version_hascrc(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_V5SB : 0) |
+                       (xfs_sb_version_hasftype(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_FTYPE : 0) |
+                       (xfs_sb_version_hasfinobt(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_FINOBT : 0) |
+                       (xfs_sb_version_hassparseinodes(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_SPINODES : 0) |
+                       (xfs_sb_version_hasrmapbt(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_RMAPBT : 0) |
+                       (xfs_sb_version_hasreflink(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_REFLINK : 0);
+               geo->logsectsize = xfs_sb_version_hassector(&mp->m_sb) ?
+                               mp->m_sb.sb_logsectsize : BBSIZE;
+               geo->rtsectsize = mp->m_sb.sb_blocksize;
+               geo->dirblocksize = mp->m_dir_geo->blksize;
+       }
+       if (new_version >= 4) {
+               geo->flags |=
+                       (xfs_sb_version_haslogv2(&mp->m_sb) ?
+                               XFS_FSOP_GEOM_FLAGS_LOGV2 : 0);
+               geo->logsunit = mp->m_sb.sb_logsunit;
+       }
+       return 0;
+}
index 961e6475a3099bb9acf2c5df67f355f35ffbb3c7..a16632c2a332393dd5c90d486f44d7183194b40a 100644 (file)
@@ -34,4 +34,7 @@ extern void   xfs_sb_from_disk(struct xfs_sb *to, struct xfs_dsb *from);
 extern void    xfs_sb_to_disk(struct xfs_dsb *to, struct xfs_sb *from);
 extern void    xfs_sb_quota_from_disk(struct xfs_sb *sbp);
 
+extern int     xfs_fs_geometry(struct xfs_mount *mp, struct xfs_fsop_geom *geo,
+                               int nversion);
+
 #endif /* __XFS_SB_H__ */
index 60a2e128cb6a59aa7181faa5c519d511a308bc5c..84d73835c614cab8750cf927ddf8fb8d0741fa5b 100644 (file)
  * File system operations
  */
 
-int
-xfs_fs_geometry(
-       xfs_mount_t             *mp,
-       xfs_fsop_geom_t         *geo,
-       int                     new_version)
-{
-
-       memset(geo, 0, sizeof(*geo));
-
-       geo->blocksize = mp->m_sb.sb_blocksize;
-       geo->rtextsize = mp->m_sb.sb_rextsize;
-       geo->agblocks = mp->m_sb.sb_agblocks;
-       geo->agcount = mp->m_sb.sb_agcount;
-       geo->logblocks = mp->m_sb.sb_logblocks;
-       geo->sectsize = mp->m_sb.sb_sectsize;
-       geo->inodesize = mp->m_sb.sb_inodesize;
-       geo->imaxpct = mp->m_sb.sb_imax_pct;
-       geo->datablocks = mp->m_sb.sb_dblocks;
-       geo->rtblocks = mp->m_sb.sb_rblocks;
-       geo->rtextents = mp->m_sb.sb_rextents;
-       geo->logstart = mp->m_sb.sb_logstart;
-       ASSERT(sizeof(geo->uuid)==sizeof(mp->m_sb.sb_uuid));
-       memcpy(geo->uuid, &mp->m_sb.sb_uuid, sizeof(mp->m_sb.sb_uuid));
-       if (new_version >= 2) {
-               geo->sunit = mp->m_sb.sb_unit;
-               geo->swidth = mp->m_sb.sb_width;
-       }
-       if (new_version >= 3) {
-               geo->version = XFS_FSOP_GEOM_VERSION;
-               geo->flags = XFS_FSOP_GEOM_FLAGS_NLINK |
-                            XFS_FSOP_GEOM_FLAGS_DIRV2 |
-                       (xfs_sb_version_hasattr(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_ATTR : 0) |
-                       (xfs_sb_version_hasquota(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_QUOTA : 0) |
-                       (xfs_sb_version_hasalign(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_IALIGN : 0) |
-                       (xfs_sb_version_hasdalign(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_DALIGN : 0) |
-                       (xfs_sb_version_hasextflgbit(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_EXTFLG : 0) |
-                       (xfs_sb_version_hassector(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_SECTOR : 0) |
-                       (xfs_sb_version_hasasciici(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_DIRV2CI : 0) |
-                       (xfs_sb_version_haslazysbcount(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_LAZYSB : 0) |
-                       (xfs_sb_version_hasattr2(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_ATTR2 : 0) |
-                       (xfs_sb_version_hasprojid32bit(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_PROJID32 : 0) |
-                       (xfs_sb_version_hascrc(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_V5SB : 0) |
-                       (xfs_sb_version_hasftype(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_FTYPE : 0) |
-                       (xfs_sb_version_hasfinobt(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_FINOBT : 0) |
-                       (xfs_sb_version_hassparseinodes(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_SPINODES : 0) |
-                       (xfs_sb_version_hasrmapbt(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_RMAPBT : 0) |
-                       (xfs_sb_version_hasreflink(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_REFLINK : 0);
-               geo->logsectsize = xfs_sb_version_hassector(&mp->m_sb) ?
-                               mp->m_sb.sb_logsectsize : BBSIZE;
-               geo->rtsectsize = mp->m_sb.sb_blocksize;
-               geo->dirblocksize = mp->m_dir_geo->blksize;
-       }
-       if (new_version >= 4) {
-               geo->flags |=
-                       (xfs_sb_version_haslogv2(&mp->m_sb) ?
-                               XFS_FSOP_GEOM_FLAGS_LOGV2 : 0);
-               geo->logsunit = mp->m_sb.sb_logsunit;
-       }
-       return 0;
-}
-
 static struct xfs_buf *
 xfs_growfs_get_hdr_buf(
        struct xfs_mount        *mp,
index 2954c13a3acd2f044bf6c6a0c3988e673c900a70..20484ed5e919af18144faf9b4e639a21b50ef6f2 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef __XFS_FSOPS_H__
 #define        __XFS_FSOPS_H__
 
-extern int xfs_fs_geometry(xfs_mount_t *mp, xfs_fsop_geom_t *geo, int nversion);
 extern int xfs_growfs_data(xfs_mount_t *mp, xfs_growfs_data_t *in);
 extern int xfs_growfs_log(xfs_mount_t *mp, xfs_growfs_log_t *in);
 extern int xfs_fs_counts(xfs_mount_t *mp, xfs_fsop_counts_t *cnt);
index 20dc65fef6a42fa52ad412b9cd5619aa1434245b..3015e178d028e016610b695b32b31cf2a2d770ec 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/fsmap.h>
 #include "xfs_fsmap.h"
 #include "scrub/xfs_scrub.h"
+#include "xfs_sb.h"
 
 #include <linux/capability.h>
 #include <linux/cred.h>
index 35c79e246fdebe092d93b020b84a52ee6d3763c0..66cc3cd7026852a33779386483af8072b9a2dabd 100644 (file)
@@ -37,6 +37,7 @@
 #include "xfs_ioctl.h"
 #include "xfs_ioctl32.h"
 #include "xfs_trace.h"
+#include "xfs_sb.h"
 
 #define  _NATIVE_IOC(cmd, type) \
          _IOC(_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), sizeof(type))