]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfsprogs: Start using pquotaino from on-disk superblock
authorChandra Seetharaman <sekharan@us.ibm.com>
Thu, 1 Aug 2013 19:25:01 +0000 (19:25 +0000)
committerRich Johnston <rjohnston@sgi.com>
Wed, 14 Aug 2013 18:57:26 +0000 (13:57 -0500)
Start using the new field sb_pquotino from the on-disk superblock if the
version of the superblock supports separate pquotino.

Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Reviewed-by: Rich Johnston <rjohnston@sgi.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
17 files changed:
db/check.c
db/dquot.c
db/frag.c
db/inode.c
db/metadump.c
include/xfs_sb.h
libxfs/xfs_mount.c
mkfs/xfs_mkfs.c
repair/agheader.c
repair/dinode.c
repair/dir2.c
repair/globals.h
repair/phase4.c
repair/phase6.c
repair/sb.c
repair/versions.c
repair/xfs_repair.c

index d66dc686df4b56f20dd8f599b9de10b2211cd6b4..cbe55badcbb67c35d570b697eba7339808ffa296 100644 (file)
@@ -1835,7 +1835,8 @@ init(
        if (mp->m_sb.sb_inoalignmt)
                sbversion |= XFS_SB_VERSION_ALIGNBIT;
        if ((mp->m_sb.sb_uquotino && mp->m_sb.sb_uquotino != NULLFSINO) ||
-           (mp->m_sb.sb_gquotino && mp->m_sb.sb_gquotino != NULLFSINO))
+           (mp->m_sb.sb_gquotino && mp->m_sb.sb_gquotino != NULLFSINO) ||
+           (mp->m_sb.sb_pquotino && mp->m_sb.sb_pquotino != NULLFSINO))
                sbversion |= XFS_SB_VERSION_QUOTABIT;
        quota_init();
        return 1;
@@ -2732,7 +2733,8 @@ process_inode(
                        addlink_inode(id);
                }
                else if (id->ino == mp->m_sb.sb_uquotino ||
-                        id->ino == mp->m_sb.sb_gquotino) {
+                        id->ino == mp->m_sb.sb_gquotino ||
+                        id->ino == mp->m_sb.sb_pquotino) {
                        type = DBM_QUOTA;
                        blkmap = blkmap_alloc(idic.di_nextents);
                        addlink_inode(id);
@@ -2853,7 +2855,7 @@ process_inode(
                         (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) &&
                         (mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD))
                        process_quota(IS_GROUP_QUOTA, id, blkmap);
-               else if (id->ino == mp->m_sb.sb_gquotino &&
+               else if (id->ino == mp->m_sb.sb_pquotino &&
                         (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) &&
                         (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD))
                        process_quota(IS_PROJECT_QUOTA, id, blkmap);
@@ -3624,8 +3626,8 @@ quota_init(void)
               mp->m_sb.sb_gquotino != NULLFSINO &&
               (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) &&
               (mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD);
-       qpdo = mp->m_sb.sb_gquotino != 0 &&
-              mp->m_sb.sb_gquotino != NULLFSINO &&
+       qpdo = mp->m_sb.sb_pquotino != 0 &&
+              mp->m_sb.sb_pquotino != NULLFSINO &&
               (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) &&
               (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD);
        if (qudo)
index 35eb0bde89058294a5d091b5df1455f98bc0e11d..69279566f73579b65286377d5409811cf6cf7534 100644 (file)
@@ -133,10 +133,13 @@ dquot_f(
                dbprintf(_("dquot command requires one %s id argument\n"), s);
                return 0;
        }
-       ino = (dogrp || doprj) ? mp->m_sb.sb_gquotino : mp->m_sb.sb_uquotino;
-       if (ino == 0 || ino == NULLFSINO ||
-           (dogrp && (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT)) ||
-           (doprj && (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT))) {
+       ino = mp->m_sb.sb_uquotino;
+       if (doprj)
+               ino = mp->m_sb.sb_pquotino;
+       else if (dogrp)
+               ino = mp->m_sb.sb_gquotino;
+
+       if (ino == 0 || ino == NULLFSINO) {
                dbprintf(_("no %s quota inode present\n"), s);
                return 0;
        }
index 23ccfa5a78875401a34bb4d7fc0aaaf8d9492f10..2eb33d87bb33de3beb72e14f84b1507d85724b40 100644 (file)
--- a/db/frag.c
+++ b/db/frag.c
@@ -326,7 +326,8 @@ process_inode(
                        skipd = 1;
                else if (!qflag &&
                         (ino == mp->m_sb.sb_uquotino ||
-                         ino == mp->m_sb.sb_gquotino))
+                         ino == mp->m_sb.sb_gquotino ||
+                         ino == mp->m_sb.sb_pquotino))
                        skipd = 1;
                else
                        skipd = !fflag;
index 68ef564aa1589d39171a272e94a5753eb692758f..eafbbd561dad9ce364cb25b4c12a9bf34b600a06 100644 (file)
@@ -438,7 +438,8 @@ inode_next_type(void)
                else if (iocur_top->ino == mp->m_sb.sb_rsumino)
                        return TYP_RTSUMMARY;
                else if (iocur_top->ino == mp->m_sb.sb_uquotino ||
-                        iocur_top->ino == mp->m_sb.sb_gquotino)
+                        iocur_top->ino == mp->m_sb.sb_gquotino ||
+                        iocur_top->ino == mp->m_sb.sb_pquotino)
                        return TYP_DQBLK;
                else
                        return TYP_DATA;
index 1c8020b471d2606b14bea6f1640acd7951e7c147..a170bb534a6eebc8ce87ea5a55fb1a932118ac4e 100644 (file)
@@ -1976,7 +1976,10 @@ copy_sb_inodes(void)
        if (!copy_ino(mp->m_sb.sb_uquotino, TYP_DQBLK))
                return 0;
 
-       return copy_ino(mp->m_sb.sb_gquotino, TYP_DQBLK);
+       if (!copy_ino(mp->m_sb.sb_gquotino, TYP_DQBLK))
+               return 0;
+
+       return copy_ino(mp->m_sb.sb_pquotino, TYP_DQBLK);
 }
 
 static int
index 51db6f224a8c11439684ba860219928cd3872a03..4a710d6514ce298c0cea83b4bd11f375aee687ce 100644 (file)
@@ -625,6 +625,11 @@ xfs_sb_has_incompat_log_feature(
        return (sbp->sb_features_log_incompat & feature) != 0;
 }
 
+static inline int xfs_sb_version_has_pquotino(xfs_sb_t *sbp)
+{
+       return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
+}
+
 /*
  * end of superblock version macros
  */
index e7a9003c52678058be53947af9b51105ec586e9b..8b267bc295ce555994a5f4f05e821dfe61d612d8 100644 (file)
@@ -326,6 +326,13 @@ xfs_sb_from_disk(
 static void
 xfs_sb_quota_from_disk(struct xfs_sb *sbp)
 {
+       /*
+        * We need to do these manipilations only if we are working
+        * with an older version of on-disk superblock.
+        */
+       if (xfs_sb_version_has_pquotino(sbp))
+               return;
+
        if (sbp->sb_qflags & XFS_OQUOTA_ENFD)
                sbp->sb_qflags |= (sbp->sb_qflags & XFS_PQUOTA_ACCT) ?
                                        XFS_PQUOTA_ENFD : XFS_GQUOTA_ENFD;
@@ -333,6 +340,18 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp)
                sbp->sb_qflags |= (sbp->sb_qflags & XFS_PQUOTA_ACCT) ?
                                        XFS_PQUOTA_CHKD : XFS_GQUOTA_CHKD;
        sbp->sb_qflags &= ~(XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD);
+
+       if (sbp->sb_qflags & XFS_PQUOTA_ACCT)  {
+               /*
+                * In older version of superblock, on-disk superblock only
+                * has sb_gquotino, and in-core superblock has both sb_gquotino
+                * and sb_pquotino. But, only one of them is supported at any
+                * point of time. So, if PQUOTA is set in disk superblock,
+                * copy over sb_gquotino to sb_pquotino.
+                */
+               sbp->sb_pquotino = sbp->sb_gquotino;
+               sbp->sb_gquotino = NULLFSINO;
+       }
 }
 
 static inline void
@@ -343,6 +362,13 @@ xfs_sb_quota_to_disk(
 {
        __uint16_t      qflags = from->sb_qflags;
 
+       /*
+        * We need to do these manipilations only if we are working
+        * with an older version of on-disk superblock.
+        */
+       if (xfs_sb_version_has_pquotino(from))
+               return;
+
        if (*fields & XFS_SB_QFLAGS) {
                /*
                 * The in-core version of sb_qflags do not have
@@ -362,6 +388,21 @@ xfs_sb_quota_to_disk(
                to->sb_qflags = cpu_to_be16(qflags);
                *fields &= ~XFS_SB_QFLAGS;
        }
+
+       /*
+        * GQUOTINO and PQUOTINO cannot be used together in versions
+        * of superblock that do not have pquotino. from->sb_flags
+        * tells us which quota is active and should be copied to
+        * disk.
+        */
+       if ((*fields & XFS_SB_GQUOTINO) &&
+                               (from->sb_qflags & XFS_GQUOTA_ACCT))
+               to->sb_gquotino = cpu_to_be64(from->sb_gquotino);
+       else if ((*fields & XFS_SB_PQUOTINO) &&
+                               (from->sb_qflags & XFS_PQUOTA_ACCT))
+               to->sb_gquotino = cpu_to_be64(from->sb_pquotino);
+
+       *fields &= ~(XFS_SB_PQUOTINO | XFS_SB_GQUOTINO);
 }
 
 /*
@@ -386,6 +427,7 @@ xfs_sb_to_disk(
                return;
 
        xfs_sb_quota_to_disk(to, from, &fields);
+
        while (fields) {
                f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields);
                first = xfs_sb_info[f].offset;
index bb5d8d4eb39e399ae9e88bd21d074785ceffb16e..4bdaceed3ec247223b09c5c9f7e2aaa992a6569e 100644 (file)
@@ -2477,7 +2477,7 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
        sbp->sb_fdblocks = dblocks - agcount * XFS_PREALLOC_BLOCKS(mp) -
                (loginternal ? logblocks : 0);
        sbp->sb_frextents = 0;  /* will do a free later */
-       sbp->sb_uquotino = sbp->sb_gquotino = 0;
+       sbp->sb_uquotino = sbp->sb_gquotino = sbp->sb_pquotino = 0;
        sbp->sb_qflags = 0;
        sbp->sb_unit = dsunit;
        sbp->sb_width = dswidth;
index 79c693becf95f1915589544aafd75b58ec1acd5a..b0f38ba2abf899260b0757ec08de942a1f851390 100644 (file)
@@ -362,6 +362,19 @@ secondary_sb_wack(xfs_mount_t *mp, xfs_buf_t *sbuf, xfs_sb_t *sb,
                        rval |= XR_AG_SB_SEC;
        }
 
+       if (sb->sb_inprogress == 1 && sb->sb_pquotino)  {
+               if (!no_modify)
+                       sb->sb_pquotino = 0;
+               if (sb->sb_versionnum & XR_PART_SECSB_VNMASK || !do_bzero)  {
+                       rval |= XR_AG_SB;
+                       do_warn(
+               _("non-null project quota inode field in superblock %d\n"),
+                               i);
+
+               } else
+                       rval |= XR_AG_SB_SEC;
+       }
+
        if (sb->sb_inprogress == 1 && sb->sb_qflags)  {
                if (!no_modify)
                        sb->sb_qflags = 0;
index e607f0b4bda1e2a4b8310f3873b47305edc641a1..a1261e6f4598d26d477605d1bc837ba83f769b76 100644 (file)
@@ -1812,6 +1812,15 @@ process_check_sb_inodes(
                }
                return 0;
        }
+       if (lino == mp->m_sb.sb_pquotino)  {
+               if (*type != XR_INO_DATA)  {
+                       do_warn(_("project quota inode %" PRIu64 " has bad type 0x%x\n"),
+                               lino, dinode_fmt(dinoc));
+                       mp->m_sb.sb_pquotino = NULLFSINO;
+                       return 1;
+               }
+               return 0;
+       }
        if (lino == mp->m_sb.sb_rsumino) {
                if (*type != XR_INO_RTSUM) {
                        do_warn(
index 2ca7fd1bd10a4b4a9819eaefaa224aa7500e2cb2..05bd4b7660e25a3d6e9d25a1ad9015d98be0b26a 100644 (file)
@@ -817,6 +817,9 @@ process_sf_dir2(
                } else if (lino == mp->m_sb.sb_gquotino)  {
                        junkit = 1;
                        junkreason = _("group quota");
+               } else if (lino == mp->m_sb.sb_pquotino)  {
+                       junkit = 1;
+                       junkreason = _("project quota");
                } else if ((irec_p = find_inode_rec(mp,
                                        XFS_INO_TO_AGNO(mp, lino),
                                        XFS_INO_TO_AGINO(mp, lino))) != NULL) {
@@ -1332,6 +1335,8 @@ process_dir2_data(
                        clearreason = _("user quota");
                } else if (ent_ino == mp->m_sb.sb_gquotino) {
                        clearreason = _("group quota");
+               } else if (ent_ino == mp->m_sb.sb_pquotino) {
+                       clearreason = _("project quota");
                } else {
                        irec_p = find_inode_rec(mp,
                                                XFS_INO_TO_AGNO(mp, ent_ino),
index e01e4e9973f876a2b5b76af81da2ff859b696c77..aef8b793607b92b4d6b1b4476b2a8d672fb6b9e8 100644 (file)
@@ -137,6 +137,7 @@ EXTERN int          need_rsumino;
 EXTERN int             lost_quotas;
 EXTERN int             have_uquotino;
 EXTERN int             have_gquotino;
+EXTERN int             have_pquotino;
 EXTERN int             lost_uquotino;
 EXTERN int             lost_gquotino;
 EXTERN int             lost_pquotino;
index a6c7a5e9fd31cb69e0c545dd1a333f67f16c084d..a822aaab3bd96ed0df95449146c2cb4b0bebcc92 100644 (file)
@@ -71,12 +71,25 @@ quotino_check(xfs_mount_t *mp)
                if (irec == NULL || is_inode_free(irec,
                                mp->m_sb.sb_gquotino - irec->ino_startnum))  {
                        mp->m_sb.sb_gquotino = NULLFSINO;
-                       if (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT)
-                               lost_gquotino = 1;
-                       else
-                               lost_pquotino = 1;
+                       lost_gquotino = 1;
                } else
-                       lost_gquotino = lost_pquotino = 0;
+                       lost_gquotino = 0;
+       }
+
+       if (mp->m_sb.sb_pquotino != NULLFSINO && mp->m_sb.sb_pquotino != 0)  {
+               if (verify_inum(mp, mp->m_sb.sb_pquotino))
+                       irec = NULL;
+               else
+                       irec = find_inode_rec(mp,
+                               XFS_INO_TO_AGNO(mp, mp->m_sb.sb_pquotino),
+                               XFS_INO_TO_AGINO(mp, mp->m_sb.sb_pquotino));
+
+               if (irec == NULL || is_inode_free(irec,
+                               mp->m_sb.sb_pquotino - irec->ino_startnum))  {
+                       mp->m_sb.sb_pquotino = NULLFSINO;
+                       lost_pquotino = 1;
+               } else
+                       lost_pquotino = 0;
        }
 }
 
@@ -104,11 +117,13 @@ quota_sb_check(xfs_mount_t *mp)
 
        if (fs_quotas &&
            (mp->m_sb.sb_uquotino == NULLFSINO || mp->m_sb.sb_uquotino == 0) &&
-           (mp->m_sb.sb_gquotino == NULLFSINO || mp->m_sb.sb_gquotino == 0))  {
+           (mp->m_sb.sb_gquotino == NULLFSINO || mp->m_sb.sb_gquotino == 0) &&
+           (mp->m_sb.sb_pquotino == NULLFSINO || mp->m_sb.sb_pquotino == 0))  {
                lost_quotas = 1;
                fs_quotas = 0;
        } else if (!verify_inum(mp, mp->m_sb.sb_uquotino) &&
-                       !verify_inum(mp, mp->m_sb.sb_gquotino)) {
+                       !verify_inum(mp, mp->m_sb.sb_gquotino) &&
+                       !verify_inum(mp, mp->m_sb.sb_pquotino)) {
                fs_quotas = 1;
        }
 }
index a60e760c5c8c9683ce503f9fd4679d0591d601c7..f94cdaf005a60db7de13f0d50d4381cb3ce7cb8f 100644 (file)
@@ -2785,6 +2785,15 @@ mark_standalone_inodes(xfs_mount_t *mp)
                                        - irec->ino_startnum;
                        add_inode_reached(irec, offset);
                }
+               if (mp->m_sb.sb_pquotino
+                               && mp->m_sb.sb_pquotino != NULLFSINO)  {
+                       irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp,
+                                               mp->m_sb.sb_pquotino),
+                               XFS_INO_TO_AGINO(mp, mp->m_sb.sb_pquotino));
+                       offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_pquotino)
+                                       - irec->ino_startnum;
+                       add_inode_reached(irec, offset);
+               }
        }
 }
 
index c7786b54d879b41c74033353b0bbc533528418de..e2f59337e30519e856c1744f75adb30a996680cb 100644 (file)
@@ -40,6 +40,7 @@ copy_sb(xfs_sb_t *source, xfs_sb_t *dest)
        xfs_ino_t       rsumino;
        xfs_ino_t       uquotino;
        xfs_ino_t       gquotino;
+       xfs_ino_t       pquotino;
        __uint16_t      versionnum;
 
        rootino = dest->sb_rootino;
@@ -47,6 +48,7 @@ copy_sb(xfs_sb_t *source, xfs_sb_t *dest)
        rsumino = dest->sb_rsumino;
        uquotino = dest->sb_uquotino;
        gquotino = dest->sb_gquotino;
+       pquotino = dest->sb_pquotino;
 
        versionnum = dest->sb_versionnum;
 
@@ -57,6 +59,7 @@ copy_sb(xfs_sb_t *source, xfs_sb_t *dest)
        dest->sb_rsumino = rsumino;
        dest->sb_uquotino = uquotino;
        dest->sb_gquotino = gquotino;
+       dest->sb_pquotino = pquotino;
 
        dest->sb_versionnum = versionnum;
 
index b65747a0ddcb0be17c5d28baca9611c75ce1c0cb..c1dff72a8906d3386fe7cd511549a7b9a1ca27a7 100644 (file)
@@ -117,6 +117,7 @@ parse_sb_version(xfs_sb_t *sb)
        fs_has_extflgbit = 0;
        have_uquotino = 0;
        have_gquotino = 0;
+       have_pquotino = 0;
        issue_warning = 0;
 
        /*
@@ -253,6 +254,10 @@ _("WARNING:  you have disallowed quotas but this filesystem\n"
                        if (sb->sb_gquotino != 0 &&
                                        sb->sb_gquotino != NULLFSINO)
                                have_gquotino = 1;
+
+                       if (sb->sb_pquotino != 0 &&
+                                       sb->sb_pquotino != NULLFSINO)
+                               have_pquotino = 1;
                }
        }
 
index ab0620159f537c1fe854d37efa5af3cc70645e36..820e7a29fa1134c5a7d463ce49a7eccf5cc20562 100644 (file)
@@ -775,7 +775,7 @@ main(int argc, char **argv)
 _("Inode allocation btrees are too corrupted, skipping phases 6 and 7\n"));
        }
 
-       if (lost_quotas && !have_uquotino && !have_gquotino {
+       if (lost_quotas && !have_uquotino && !have_gquotino && !have_pquotino) {
                if (!no_modify)  {
                        do_warn(
 _("Warning:  no quota inodes were found.  Quotas disabled.\n"));