From 53f8ad6d9d4f9b0f374b87b10844abc8ee9b5f09 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Wed, 13 Nov 2002 06:59:25 +0000 Subject: [PATCH] Minor update - include less kernel headers, abstract some Linux/IRIX diffs in growfs to more easily keep track of changes there. Add in explore source file targets. --- growfs/Makefile | 4 +- growfs/explore.c | 109 +++++++++++++++++++++++++++++++++++ growfs/explore.h | 48 ++++++++++++++++ growfs/xfs_growfs.c | 89 ++++------------------------- include/xfs_fs.h | 12 ++-- include/xfs_types.h | 134 ++++---------------------------------------- include/xqm.h | 8 +-- libxfs/xfs.h | 3 + 8 files changed, 195 insertions(+), 212 deletions(-) create mode 100644 growfs/explore.c create mode 100644 growfs/explore.h diff --git a/growfs/Makefile b/growfs/Makefile index aa82b4d36..7bae9bf9c 100644 --- a/growfs/Makefile +++ b/growfs/Makefile @@ -35,7 +35,9 @@ include $(TOPDIR)/include/builddefs LTCOMMAND = xfs_growfs -CFILES = xfs_growfs.c +CFILES = explore.c xfs_growfs.c +HFILES = explore.h + LLDLIBS = $(LIBXFS) $(LIBUUID) LTDEPENDENCIES = $(LIBXFS) LLDFLAGS = -static diff --git a/growfs/explore.c b/growfs/explore.c new file mode 100644 index 000000000..27c184ec6 --- /dev/null +++ b/growfs/explore.c @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include +#include + +extern char *fname; /* mount point name */ +extern char *datadev; /* data device name */ +extern char *logdev; /* log device name */ +extern char *rtdev; /* RT device name */ + +void +explore_mtab(char *mtab, char *mntpoint) +{ + struct mntent *mnt; + struct stat64 statuser; + struct stat64 statmtab; + FILE *mtp; + char *rtend; + char *logend; + + if (!mtab) + mtab = MOUNTED; + + if ((mtp = setmntent(mtab, "r")) == NULL) { + fprintf(stderr, "%s: cannot access mount list %s: %s\n", + progname, MOUNTED, strerror(errno)); + exit(1); + } + if (stat64(mntpoint, &statuser) < 0) { + fprintf(stderr, "%s: cannot access mount point %s: %s\n", + progname, mntpoint, strerror(errno)); + exit(1); + } + + while ((mnt = getmntent(mtp)) != NULL) { + if (stat64(mnt->mnt_dir, &statmtab) < 0) { + fprintf(stderr, "%s: ignoring entry %s in %s: %s\n", + progname, mnt->mnt_dir, mtab, strerror(errno)); + continue; + } + if (statuser.st_ino != statmtab.st_ino || + statuser.st_dev != statmtab.st_dev) + continue; + else if (strcmp(mnt->mnt_type, "xfs") != 0) { + fprintf(stderr, "%s: %s is not an XFS filesystem\n", + progname, mntpoint); + exit(1); + } + break; /* we've found it */ + } + + if (mnt == NULL) { + fprintf(stderr, + "%s: %s is not a filesystem mount point, according to %s\n", + progname, mntpoint, MOUNTED); + exit(1); + } + + /* find the data, log (logdev=), and realtime (rtdev=) devices */ + rtend = logend = NULL; + fname = mnt->mnt_dir; + datadev = mnt->mnt_fsname; + if ((logdev = hasmntopt(mnt, "logdev="))) { + logdev += 7; + logend = strtok(logdev, " ,"); + } + if ((rtdev = hasmntopt(mnt, "rtdev="))) { + rtdev += 6; + rtend = strtok(rtdev, " ,"); + } + + /* Do this only after we've finished processing mount options */ + if (logdev && logend != logdev) + *logend = '\0'; /* terminate end of log device name */ + if (rtdev && rtend != rtdev) + *rtend = '\0'; /* terminate end of rt device name */ + + endmntent(mtp); +} diff --git a/growfs/explore.h b/growfs/explore.h new file mode 100644 index 000000000..8f2b480ba --- /dev/null +++ b/growfs/explore.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ +#ifndef XFS_GROWFS_EXPLORE_H +#define XFS_GROWFS_EXPLORE_H + +/* + * This was written as part of the Linux port. On IRIX, + * the volume managers have knowledge of log and realtime + * subvolumes, and the equivalent functionality is built + * into the kernel - XFS/XLV/XVM talk amongst themselves + * and there are no rtdev/logdev mount parameters at all. + */ +#ifdef __linux__ +extern void explore_mtab(char *mtab, char *mntpoint); +#else +# define explore_mtab(mtab, mpoint) do { } while (0) +#endif + +#endif /* XFS_GROWFS_EXPLORE_H */ diff --git a/growfs/xfs_growfs.c b/growfs/xfs_growfs.c index ab883cd51..3ab380a32 100644 --- a/growfs/xfs_growfs.c +++ b/growfs/xfs_growfs.c @@ -31,8 +31,8 @@ */ #include -#include #include +#include "explore.h" /* * When growing a filesystem, this is the most significant @@ -42,10 +42,10 @@ #define XFS_MAX_INODE_SIG_BITS 32 -static char *fname; /* mount point name */ -static char *datadev; /* data device name */ -static char *logdev; /* log device name */ -static char *rtdev; /* RT device name */ +char *fname; /* mount point name */ +char *datadev; /* data device name */ +char *logdev; /* log device name */ +char *rtdev; /* RT device name */ static void usage(void) @@ -99,73 +99,6 @@ report_info( (long long)geo.rtblocks, (long long)geo.rtextents); } -void -explore_mtab(char *mtab, char *mntpoint) -{ - struct mntent *mnt; - struct stat64 statuser; - struct stat64 statmtab; - FILE *mtp; - char *rtend; - char *logend; - - if ((mtp = setmntent(mtab, "r")) == NULL) { - fprintf(stderr, "%s: cannot access mount list %s: %s\n", - progname, MOUNTED, strerror(errno)); - exit(1); - } - if (stat64(mntpoint, &statuser) < 0) { - fprintf(stderr, "%s: cannot access mount point %s: %s\n", - progname, mntpoint, strerror(errno)); - exit(1); - } - - while ((mnt = getmntent(mtp)) != NULL) { - if (stat64(mnt->mnt_dir, &statmtab) < 0) { - fprintf(stderr, "%s: ignoring entry %s in %s: %s\n", - progname, mnt->mnt_dir, mtab, strerror(errno)); - continue; - } - if (statuser.st_ino != statmtab.st_ino || - statuser.st_dev != statmtab.st_dev) - continue; - else if (strcmp(mnt->mnt_type, "xfs") != 0) { - fprintf(stderr, "%s: %s is not an XFS filesystem\n", - progname, mntpoint); - exit(1); - } - break; /* we've found it */ - } - - if (mnt == NULL) { - fprintf(stderr, - "%s: %s is not a filesystem mount point, according to %s\n", - progname, mntpoint, MOUNTED); - exit(1); - } - - /* find the data, log (logdev=), and realtime (rtdev=) devices */ - rtend = logend = NULL; - fname = mnt->mnt_dir; - datadev = mnt->mnt_fsname; - if ((logdev = hasmntopt(mnt, "logdev="))) { - logdev += 7; - logend = strtok(logdev, " ,"); - } - if ((rtdev = hasmntopt(mnt, "rtdev="))) { - rtdev += 6; - rtend = strtok(rtdev, " ,"); - } - - /* Do this only after we've finished processing mount options */ - if (logdev && logend != logdev) - *logend = '\0'; /* terminate end of log device name */ - if (rtdev && rtend != rtdev) - *rtend = '\0'; /* terminate end of rt device name */ - - endmntent(mtp); -} - int main(int argc, char **argv) { @@ -197,15 +130,17 @@ main(int argc, char **argv) int xflag; /* -x flag */ libxfs_init_t xi; /* libxfs structure */ - mtab = MOUNTED; progname = basename(argv[0]); - aflag = dflag = iflag = lflag = mflag = nflag = rflag = xflag = 0; + + mtab = NULL; maxpct = esize = 0; dsize = lsize = rsize = 0LL; + aflag = dflag = iflag = lflag = mflag = nflag = rflag = xflag = 0; + while ((c = getopt(argc, argv, "dD:e:ilL:m:np:rR:t:xV")) != EOF) { switch (c) { case 'D': - dsize = atoll(optarg); + dsize = strtoll(optarg, NULL, 10); /* fall through */ case 'd': dflag = 1; @@ -218,7 +153,7 @@ main(int argc, char **argv) lflag = iflag = 1; break; case 'L': - lsize = atoll(optarg); + lsize = strtoll(optarg, NULL, 10); /* fall through */ case 'l': lflag = 1; @@ -234,7 +169,7 @@ main(int argc, char **argv) progname = optarg; break; case 'R': - rsize = atoll(optarg); + rsize = strtoll(optarg, NULL, 10); /* fall through */ case 'r': rflag = 1; diff --git a/include/xfs_fs.h b/include/xfs_fs.h index 0311d1258..a50ee40bf 100644 --- a/include/xfs_fs.h +++ b/include/xfs_fs.h @@ -30,12 +30,8 @@ * * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ */ -#ifndef _LINUX_XFS_FS_H -#define _LINUX_XFS_FS_H - -#include -#include - +#ifndef __XFS_FS_H__ +#define __XFS_FS_H__ /* * SGI's XFS filesystem's major stuff (constants, structures) @@ -394,11 +390,13 @@ typedef struct { * This is typically called by a stateless file server in order to generate * "file handles". */ +#ifndef MAXFIDSZ #define MAXFIDSZ 46 typedef struct fid { __u16 fid_len; /* length of data in bytes */ unsigned char fid_data[MAXFIDSZ]; /* data (variable length) */ } fid_t; +#endif typedef struct xfs_fid { __u16 xfs_fid_len; /* length of remainder */ @@ -499,4 +497,4 @@ typedef struct xfs_handle { #define BTOBBT(bytes) ((__u64)(bytes) >> BBSHIFT) #define BBTOB(bbs) ((bbs) << BBSHIFT) -#endif /* _LINUX_XFS_FS_H */ +#endif /* __XFS_FS_H__ */ diff --git a/include/xfs_types.h b/include/xfs_types.h index e08f8b727..d831799bf 100644 --- a/include/xfs_types.h +++ b/include/xfs_types.h @@ -34,8 +34,6 @@ #ifdef __KERNEL__ -#include - /* * POSIX Extensions */ @@ -56,9 +54,6 @@ typedef unsigned int __uint32_t; typedef signed long long int __int64_t; typedef unsigned long long int __uint64_t; -typedef enum { B_FALSE, B_TRUE } boolean_t; - - typedef __int64_t prid_t; /* project ID */ typedef __uint32_t inst_t; /* an instruction */ @@ -68,11 +63,17 @@ typedef __s64 xfs_daddr_t; /* type */ typedef char * xfs_caddr_t; /* type */ typedef __u32 xfs_dev_t; -typedef struct timespec timespec_t; +typedef struct xfs_dirent { /* data from readdir() */ + xfs_ino_t d_ino; /* inode number of entry */ + xfs_off_t d_off; /* offset of disk directory entry */ + unsigned short d_reclen; /* length of this record */ + char d_name[1]; /* name of file */ +} xfs_dirent_t; -typedef struct { - unsigned char __u_bits[16]; -} uuid_t; +#define DIRENTBASESIZE (((xfs_dirent_t *)0)->d_name - (char *)0) +#define DIRENTSIZE(namelen) \ + ((DIRENTBASESIZE + (namelen) + \ + sizeof(xfs_off_t)) & ~(sizeof(xfs_off_t) - 1)) /* __psint_t is the same size as a pointer */ #if (BITS_PER_LONG == 32) @@ -151,7 +152,7 @@ typedef __uint64_t xfs_fileoff_t; /* block number in a file */ typedef __int64_t xfs_sfiloff_t; /* signed block number in a file */ typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */ -typedef __uint8_t xfs_arch_t; /* architecutre of an xfs fs */ +typedef __uint8_t xfs_arch_t; /* architecture of an xfs fs */ /* * Null values for the types. @@ -195,119 +196,6 @@ typedef enum { } xfs_btnum_t; -#if defined(CONFIG_PROC_FS) && defined(__KERNEL__) && !defined(XFS_STATS_OFF) -/* - * XFS global statistics - */ -struct xfsstats { -# define XFSSTAT_END_EXTENT_ALLOC 4 - __uint32_t xs_allocx; - __uint32_t xs_allocb; - __uint32_t xs_freex; - __uint32_t xs_freeb; -# define XFSSTAT_END_ALLOC_BTREE (XFSSTAT_END_EXTENT_ALLOC+4) - __uint32_t xs_abt_lookup; - __uint32_t xs_abt_compare; - __uint32_t xs_abt_insrec; - __uint32_t xs_abt_delrec; -# define XFSSTAT_END_BLOCK_MAPPING (XFSSTAT_END_ALLOC_BTREE+7) - __uint32_t xs_blk_mapr; - __uint32_t xs_blk_mapw; - __uint32_t xs_blk_unmap; - __uint32_t xs_add_exlist; - __uint32_t xs_del_exlist; - __uint32_t xs_look_exlist; - __uint32_t xs_cmp_exlist; -# define XFSSTAT_END_BLOCK_MAP_BTREE (XFSSTAT_END_BLOCK_MAPPING+4) - __uint32_t xs_bmbt_lookup; - __uint32_t xs_bmbt_compare; - __uint32_t xs_bmbt_insrec; - __uint32_t xs_bmbt_delrec; -# define XFSSTAT_END_DIRECTORY_OPS (XFSSTAT_END_BLOCK_MAP_BTREE+4) - __uint32_t xs_dir_lookup; - __uint32_t xs_dir_create; - __uint32_t xs_dir_remove; - __uint32_t xs_dir_getdents; -# define XFSSTAT_END_TRANSACTIONS (XFSSTAT_END_DIRECTORY_OPS+3) - __uint32_t xs_trans_sync; - __uint32_t xs_trans_async; - __uint32_t xs_trans_empty; -# define XFSSTAT_END_INODE_OPS (XFSSTAT_END_TRANSACTIONS+7) - __uint32_t xs_ig_attempts; - __uint32_t xs_ig_found; - __uint32_t xs_ig_frecycle; - __uint32_t xs_ig_missed; - __uint32_t xs_ig_dup; - __uint32_t xs_ig_reclaims; - __uint32_t xs_ig_attrchg; -# define XFSSTAT_END_LOG_OPS (XFSSTAT_END_INODE_OPS+5) - __uint32_t xs_log_writes; - __uint32_t xs_log_blocks; - __uint32_t xs_log_noiclogs; - __uint32_t xs_log_force; - __uint32_t xs_log_force_sleep; -# define XFSSTAT_END_TAIL_PUSHING (XFSSTAT_END_LOG_OPS+10) - __uint32_t xs_try_logspace; - __uint32_t xs_sleep_logspace; - __uint32_t xs_push_ail; - __uint32_t xs_push_ail_success; - __uint32_t xs_push_ail_pushbuf; - __uint32_t xs_push_ail_pinned; - __uint32_t xs_push_ail_locked; - __uint32_t xs_push_ail_flushing; - __uint32_t xs_push_ail_restarts; - __uint32_t xs_push_ail_flush; -# define XFSSTAT_END_WRITE_CONVERT (XFSSTAT_END_TAIL_PUSHING+2) - __uint32_t xs_xstrat_quick; - __uint32_t xs_xstrat_split; -# define XFSSTAT_END_READ_WRITE_OPS (XFSSTAT_END_WRITE_CONVERT+2) - __uint32_t xs_write_calls; - __uint32_t xs_read_calls; -# define XFSSTAT_END_ATTRIBUTE_OPS (XFSSTAT_END_READ_WRITE_OPS+4) - __uint32_t xs_attr_get; - __uint32_t xs_attr_set; - __uint32_t xs_attr_remove; - __uint32_t xs_attr_list; -# define XFSSTAT_END_QUOTA_OPS (XFSSTAT_END_ATTRIBUTE_OPS+8) - __uint32_t xs_qm_dqreclaims; - __uint32_t xs_qm_dqreclaim_misses; - __uint32_t xs_qm_dquot_dups; - __uint32_t xs_qm_dqcachemisses; - __uint32_t xs_qm_dqcachehits; - __uint32_t xs_qm_dqwants; - __uint32_t xs_qm_dqshake_reclaims; - __uint32_t xs_qm_dqinact_reclaims; -# define XFSSTAT_END_INODE_CLUSTER (XFSSTAT_END_QUOTA_OPS+3) - __uint32_t xs_iflush_count; - __uint32_t xs_icluster_flushcnt; - __uint32_t xs_icluster_flushinode; -# define XFSSTAT_END_VNODE_OPS (XFSSTAT_END_INODE_CLUSTER+8) - __uint32_t vn_active; /* # vnodes not on free lists */ - __uint32_t vn_alloc; /* # times vn_alloc called */ - __uint32_t vn_get; /* # times vn_get called */ - __uint32_t vn_hold; /* # times vn_hold called */ - __uint32_t vn_rele; /* # times vn_rele called */ - __uint32_t vn_reclaim; /* # times vn_reclaim called */ - __uint32_t vn_remove; /* # times vn_remove called */ - __uint32_t vn_free; /* # times vn_free called */ -/* Extra precision counters */ - __uint64_t xs_xstrat_bytes; - __uint64_t xs_write_bytes; - __uint64_t xs_read_bytes; -}; - -extern struct xfsstats xfsstats; - -# define XFS_STATS_INC(count) ( (count)++ ) -# define XFS_STATS_DEC(count) ( (count)-- ) -# define XFS_STATS_ADD(count, inc) ( (count) += (inc) ) -#else /* !CONFIG_PROC_FS */ -# define XFS_STATS_INC(count) -# define XFS_STATS_DEC(count) -# define XFS_STATS_ADD(count, inc) -#endif /* !CONFIG_PROC_FS */ - - /* * Juggle IRIX device numbers - still used in ondisk structures */ diff --git a/include/xqm.h b/include/xqm.h index 925769dc4..63c25d6fb 100644 --- a/include/xqm.h +++ b/include/xqm.h @@ -30,10 +30,10 @@ * * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ */ -#ifndef _LINUX_XQM_H -#define _LINUX_XQM_H +#ifndef __XQM_H__ +#define __XQM_H__ -#include +#include /* * Disk quota - quotactl(2) commands for the XFS Quota Manager (XQM). @@ -156,4 +156,4 @@ typedef struct fs_quota_stat { __u16 qs_iwarnlimit; /* limit for num warnings */ } fs_quota_stat_t; -#endif /* _LINUX_XQM_H */ +#endif /* __XQM_H__ */ diff --git a/libxfs/xfs.h b/libxfs/xfs.h index 4794c9121..889a1de77 100644 --- a/libxfs/xfs.h +++ b/libxfs/xfs.h @@ -251,6 +251,9 @@ typedef struct { dev_t dev; } xfs_buftarg_t; #define TRACE_ALLOC(s,a) ((void) 0) #define TRACE_MODAGF(a,b,c) ((void) 0) #define XFS_FORCED_SHUTDOWN(mp) 0 +#define XFS_STATS_INC(count) do { } while (0) +#define XFS_STATS_DEC(count, x) do { } while (0) +#define XFS_STATS_ADD(count, x) do { } while (0) #define XFS_MOUNT_WSYNC 0 /* ignored in userspace */ #define XFS_MOUNT_NOALIGN 0 /* ignored in userspace */ #define XFS_MOUNT_32BITINODES 0x1 /* enforce in userspace */ -- 2.47.2