From a5ff7917daf6959e132a6ab0a9b76648ca13532b Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Fri, 16 Dec 2016 15:33:45 +0900 Subject: [PATCH] sbin/hammer: Don't hardcode 0 for root PFS HAMMER code doesn't hardcode 0 for root PFS (e.g. see sbin/newfs_hammer, it could be !=0 if one wants to do so). Fix the existing error messages using hardcoded 0. Also add "(root PFS)" for PFS#0 in hammer info command. --- sbin/hammer/cmd_info.c | 7 +++++-- sbin/hammer/cmd_pfs.c | 11 ++++++----- sbin/hammer/hammer.8 | 14 ++++++-------- sbin/newfs_hammer/newfs_hammer.c | 2 +- sys/vfs/hammer/hammer_btree.h | 2 +- sys/vfs/hammer/hammer_disk.h | 2 +- sys/vfs/hammer/hammer_pfs.c | 2 +- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/sbin/hammer/cmd_info.c b/sbin/hammer/cmd_info.c index d370eb110b..a43f070eb0 100644 --- a/sbin/hammer/cmd_info.c +++ b/sbin/hammer/cmd_info.c @@ -175,7 +175,7 @@ show_info(char *path) /* Pseudo-filesystem information */ printf("PFS information\n"); - printf("\tPFS ID Mode Snaps\n"); + printf("\t PFS# Mode Snaps\n"); /* Iterate all the PFSs found */ pi_first = libhammer_get_first_pfs(fip); @@ -184,7 +184,10 @@ show_info(char *path) pi->pfs_id, (pi->ismaster ? "MASTER" : "SLAVE")); snprintf(buf, 6, "%d", pi->snapcount); - printf(" %6s\n", (pi->head.error && pi->snapcount == 0) ? "-" : buf); + printf(" %6s", (pi->head.error && pi->snapcount == 0) ? "-" : buf); + if (pi->pfs_id == HAMMER_ROOT_PFSID) + printf(" (root PFS)"); + printf("\n"); } free(fsid); diff --git a/sbin/hammer/cmd_pfs.c b/sbin/hammer/cmd_pfs.c index 59b10d2421..90cb2ae840 100644 --- a/sbin/hammer/cmd_pfs.c +++ b/sbin/hammer/cmd_pfs.c @@ -104,7 +104,7 @@ getpfs(struct hammer_ioc_pseudofs_rw *pfs, const char *path) /* * Extract the PFS id. - * dirname(path) is supposed to be a directory in PFS#0. + * dirname(path) is supposed to be a directory in root PFS. */ if (scanpfsid(pfs, path) == 0) { path = dirname(path); /* strips trailing / first if any */ @@ -337,7 +337,7 @@ hammer_cmd_pseudofs_destroy(char **av, int ac) fd = getpfs(&pfs, av[0]); if (pfs.pfs_id == HAMMER_ROOT_PFSID) - errx(1, "You cannot destroy PFS#0"); + errx(1, "You cannot destroy PFS#%d", HAMMER_ROOT_PFSID); printf("You have requested that PFS#%d (%s) be destroyed\n", pfs.pfs_id, pfs.ondisk->label); @@ -401,8 +401,9 @@ hammer_cmd_pseudofs_upgrade(char **av, int ac) fd = getpfs(&pfs, av[0]); if (pfs.pfs_id == HAMMER_ROOT_PFSID) { - errx(1, "You cannot upgrade PFS#0" - " (It should already be a master)"); + errx(1, "You cannot upgrade PFS#%d" + " (It should already be a master)", + HAMMER_ROOT_PFSID); } else if (hammer_is_pfs_master(pfs.ondisk)) { errx(1, "It is already a master"); } @@ -428,7 +429,7 @@ hammer_cmd_pseudofs_downgrade(char **av, int ac) fd = getpfs(&pfs, av[0]); if (pfs.pfs_id == HAMMER_ROOT_PFSID) { - errx(1, "You cannot downgrade PFS#0"); + errx(1, "You cannot downgrade PFS#%d", HAMMER_ROOT_PFSID); } else if (hammer_is_pfs_slave(pfs.ondisk)) { errx(1, "It is already a slave"); } diff --git a/sbin/hammer/hammer.8 b/sbin/hammer/hammer.8 index 3ba17833a6..6c3dc8929e 100644 --- a/sbin/hammer/hammer.8 +++ b/sbin/hammer/hammer.8 @@ -30,7 +30,7 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 10, 2016 +.Dd December 16, 2016 .Dt HAMMER 8 .Os .Sh NAME @@ -1210,12 +1210,11 @@ A PFS can only be truly destroyed with the directive. Removing the softlink will not destroy the underlying PFS. .Pp -A PFS can only be created in the root PFS (PFS# 0), +A PFS can only be created in the root PFS, not in a PFS created by .Cm pfs-master or -.Cm pfs-slave -(PFS# >0). +.Cm pfs-slave . .Pp It is recommended that .Ar dirpath @@ -1262,12 +1261,11 @@ A PFS can only be truly destroyed with the directive. Removing the softlink will not destroy the underlying PFS. .Pp -A PFS can only be created in the root PFS (PFS# 0), +A PFS can only be created in the root PFS, not in a PFS created by .Cm pfs-master or -.Cm pfs-slave -(PFS# >0). +.Cm pfs-slave . .Pp It is recommended that .Ar dirpath @@ -1920,7 +1918,7 @@ data must be copied separately. At last the PFS can be upgraded to master using .Cm pfs-upgrade . .Pp -It is not possible to restore the root PFS (PFS# 0) by using mirroring, +It is not possible to restore the root PFS by using mirroring, as the root PFS is always a master PFS. A normal copy (e.g.\& using .Xr cpdup 1 ) diff --git a/sbin/newfs_hammer/newfs_hammer.c b/sbin/newfs_hammer/newfs_hammer.c index ccc16d989b..91f1cbce1e 100644 --- a/sbin/newfs_hammer/newfs_hammer.c +++ b/sbin/newfs_hammer/newfs_hammer.c @@ -699,7 +699,7 @@ format_root_directory(const char *label) */ pfsd->sync_low_tid = 1; pfsd->sync_beg_tid = 0; - pfsd->sync_end_tid = 0; /* overriden by vol0_next_tid on pfs0 */ + pfsd->sync_end_tid = 0; /* overriden by vol0_next_tid on root PFS */ pfsd->shared_uuid = Hammer_FSId; pfsd->unique_uuid = Hammer_FSId; pfsd->mirror_flags = 0; diff --git a/sys/vfs/hammer/hammer_btree.h b/sys/vfs/hammer/hammer_btree.h index f89d7d6cdf..ca0b7e0c75 100644 --- a/sys/vfs/hammer/hammer_btree.h +++ b/sys/vfs/hammer/hammer_btree.h @@ -126,7 +126,7 @@ typedef struct hammer_base_elm { * * The root inode (not the PFS root inode but the real root) uses * HAMMER_DEF_LOCALIZATION for its incore ip->obj_localization. - * HAMMER_DEF_LOCALIZATION implies PFS 0 and no localization type. + * HAMMER_DEF_LOCALIZATION implies PFS#0 and no localization type. */ #define HAMMER_LOCALIZE_INODE 0x00000001 #define HAMMER_LOCALIZE_MISC 0x00000002 /* not inode */ diff --git a/sys/vfs/hammer/hammer_disk.h b/sys/vfs/hammer/hammer_disk.h index 90bf349164..130c411907 100644 --- a/sys/vfs/hammer/hammer_disk.h +++ b/sys/vfs/hammer/hammer_disk.h @@ -184,7 +184,7 @@ typedef uint32_t hammer_crc_t; * +-------------------------> vol_buf_beg + HAMMER_BIGBLOCK_SIZE * ... * | zone-8 big-block for root B-Tree node/etc * +-------------------------> vol_buf_beg + HAMMER_BIGBLOCK_SIZE * ... - * | zone-9 big-block for root inode/PFS#0/etc + * | zone-9 big-block for root inode/PFS/etc * +-------------------------> vol_buf_beg + HAMMER_BIGBLOCK_SIZE * ... * | zone-X big-blocks * | ... (big-blocks for new zones after newfs_hammer) diff --git a/sys/vfs/hammer/hammer_pfs.c b/sys/vfs/hammer/hammer_pfs.c index 92b18a42d5..7d52644f8d 100644 --- a/sys/vfs/hammer/hammer_pfs.c +++ b/sys/vfs/hammer/hammer_pfs.c @@ -397,7 +397,7 @@ hammer_pfs_autodetect(struct hammer_ioc_pseudofs_rw *pfs, hammer_inode_t ip) * * This is typically used to remove any partial syncs when upgrading a * slave to a master. It can theoretically also be used to rollback - * any PFS, including PFS#0, BUT ONLY TO POINTS THAT HAVE NOT YET BEEN + * any PFS, including root PFS, BUT ONLY TO POINTS THAT HAVE NOT YET BEEN * PRUNED, and to points that are older only if they are on a retained * (pruning softlink) boundary. * -- 2.41.0