From: Nathan Scott Date: Wed, 21 May 2003 07:25:24 +0000 (+0000) Subject: Extract device sector size at mkfs time and issue warnings if the requested filesyste... X-Git-Tag: v2.5.0~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=74668075c33873d4b7c7c7386e3d78c0cd092c7c;p=thirdparty%2Fxfsprogs-dev.git Extract device sector size at mkfs time and issue warnings if the requested filesystem sector size is too small. --- diff --git a/doc/CHANGES b/doc/CHANGES index f45688b7a..59e9c8009 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,10 @@ +[cvs] + - Extract device sector size at mkfs time and issue warnings + if the requested filesystem sector size is too small. + - Sync up user/kernel source in libxfs, libxlog and headers. + - Skip realtime initialisation in libxfs mount path if the + caller is xfs_db, otherwise we get nonsense warnings. + xfsprogs-2.4.10 (12 May 2003) - Fix a bug in mkfs - creating version 2 logs, an incorrect stripe unit value was being passed to libxfs_clear_log. diff --git a/include/libxfs.h b/include/libxfs.h index ad72e1068..c2080ca01 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -92,6 +92,7 @@ typedef struct { int risfile; /* realtime "subvolume" is a reg file */ int rcreat; /* try to create realtime subvolume */ char *notvolmsg; /* format string for not XLV message */ int notvolok; /* set if not XLV => try data */ + int setblksize; /* attempt to set device blksize */ /* output results */ dev_t ddev; /* device for data subvolume */ dev_t logdev; /* device for log subvolume */ @@ -100,11 +101,14 @@ typedef struct { long long logBBsize; /* size of log subvolume (BBs) */ /* (blocks allocated for use as * log is stored in mount structure) */ - long long logBBstart; /* start block of log subvolume (BBs) */ long long rtsize; /* size of realtime subvolume (BBs) */ + long long logBBstart; /* start block of log subvolume (BBs) */ + long long rtsize; /* size of realtime subvolume (BBs) */ + int dbsize; /* data subvolume device blksize */ + int lbsize; /* log subvolume device blksize */ + int rtbsize; /* realtime subvolume device blksize */ int dfd; /* data subvolume file descriptor */ int logfd; /* log subvolume file descriptor */ int rtfd; /* realtime subvolume file descriptor */ - int setblksize; /* attempt to set device block size */ } libxfs_init_t; #define LIBXFS_EXIT_ON_FAILURE 0x0001 /* exit the program if a call fails */ diff --git a/libxfs/darwin.c b/libxfs/darwin.c index d7a8daede..6d6ac2d8b 100644 --- a/libxfs/darwin.c +++ b/libxfs/darwin.c @@ -68,7 +68,12 @@ platform_check_iswritable(char *name, char *block, struct stat64 *s, int fatal) void platform_set_blocksize(int fd, char *path, int blocksize) { - return; +} + +int +platform_get_blocksize(int fd, char *path) +{ + return BBSIZE; } void diff --git a/libxfs/freebsd.c b/libxfs/freebsd.c index b48b48e67..d1a9d747d 100644 --- a/libxfs/freebsd.c +++ b/libxfs/freebsd.c @@ -73,6 +73,12 @@ platform_set_blocksize(int fd, char *path, int blocksize) { } +int +platform_get_blocksize(int fd, char *path) +{ + return BBSIZE; +} + void platform_flush_device(int fd) { diff --git a/libxfs/init.c b/libxfs/init.c index 8ac8ad670..d94a7c901 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -170,9 +170,9 @@ libxfs_device_close(dev_t dev) exit(1); } -int -check_open(char *path, int flags,char **rawfile,char **blockfile){ - +static int +check_open(char *path, int flags, char **rawfile, char **blockfile) +{ int readonly = (flags & LIBXFS_ISREADONLY); int inactive = (flags & LIBXFS_ISINACTIVE); int dangerously = (flags & LIBXFS_DANGEROUSLY); @@ -203,8 +203,6 @@ check_open(char *path, int flags,char **rawfile,char **blockfile){ return 1; } - - /* * libxfs initialization. * Caller gets a 0 on failure (and we print a message), 1 on success. @@ -232,8 +230,9 @@ libxfs_init(libxfs_init_t *a) dname = a->dname; logname = a->logname; rtname = a->rtname; - a->ddev = a->logdev = a->rtdev = 0; a->dfd = a->logfd = a->rtfd = -1; + a->ddev = a->logdev = a->rtdev = 0; + a->dbsize = a->lbsize = a->rtbsize = 0; a->dsize = a->logBBsize = a->logBBstart = a->rtsize = 0; (void)getcwd(curdir,MAXPATHLEN); @@ -244,7 +243,6 @@ libxfs_init(libxfs_init_t *a) flags = a->isreadonly; if (a->volname) { - if(!check_open(a->volname,flags,&rawfile,&blockfile)) goto done; needcd = 1; @@ -337,6 +335,7 @@ voldone: a->dcreat, readonly, a->setblksize); a->dfd = libxfs_device_to_fd(a->ddev); a->dsize = platform_findsize(rawfile); + a->dbsize = platform_get_blocksize(a->dfd, rawfile); } needcd = 1; } else @@ -355,6 +354,7 @@ voldone: a->lcreat, readonly, a->setblksize); a->logfd = libxfs_device_to_fd(a->logdev); a->logBBsize = platform_findsize(rawfile); + a->lbsize = platform_get_blocksize(a->logfd, rawfile); } needcd = 1; } else @@ -373,6 +373,7 @@ voldone: a->rcreat, readonly, a->setblksize); a->rtfd = libxfs_device_to_fd(a->rtdev); a->rtsize = platform_findsize(rawfile); + a->rtbsize = platform_get_blocksize(a->rtfd, rawfile); } needcd = 1; } else @@ -651,10 +652,9 @@ libxfs_mount( } /* Initialize realtime fields in the mount structure */ - if (rtmount_init(mp)) { + if (!(flags & LIBXFS_MOUNT_DEBUGGER) && rtmount_init(mp)) { fprintf(stderr, _("%s: realtime device init failed\n"), progname); - if (!(flags & LIBXFS_MOUNT_DEBUGGER)) return NULL; } @@ -682,9 +682,10 @@ libxfs_mount( } ASSERT(mp->m_rootip != NULL); } - if ((flags & LIBXFS_MOUNT_ROOTINOS) && rtmount_inodes(mp)) - if (!(flags & LIBXFS_MOUNT_DEBUGGER)) - return NULL; + if ((flags & LIBXFS_MOUNT_ROOTINOS) && + !(flags & LIBXFS_MOUNT_DEBUGGER) && + rtmount_inodes(mp)) + return NULL; return mp; } diff --git a/libxfs/init.h b/libxfs/init.h index ec93874f1..363d8c339 100644 --- a/libxfs/init.h +++ b/libxfs/init.h @@ -40,6 +40,7 @@ extern int platform_check_iswritable (char *path, char *block, struct stat64 *sptr, int fatal); extern __int64_t platform_findsize (char *path); extern void platform_set_blocksize (int fd, char *path, int blocksize); +extern int platform_get_blocksize (int fd, char *path); extern void platform_flush_device (int fd); #endif /* LIBXFS_INIT_H */ diff --git a/libxfs/irix.c b/libxfs/irix.c index d6782cc3e..f32be60b8 100644 --- a/libxfs/irix.c +++ b/libxfs/irix.c @@ -53,6 +53,12 @@ platform_set_blocksize(int fd, char *path, int blocksize) return; } +void +platform_get_blocksize(int fd, char *path) +{ + return BBSIZE; +} + void platform_flush_device(int fd) { diff --git a/libxfs/linux.c b/libxfs/linux.c index fd3be4705..068ec268e 100644 --- a/libxfs/linux.c +++ b/libxfs/linux.c @@ -47,6 +47,9 @@ extern char *progname; #ifndef BLKBSZSET # define BLKBSZSET _IOW(0x12,113,sizeof(int)) #endif +#ifndef BLKSSZGET +# define BLKSSZGET _IO(0x12,104) +#endif #define PROC_MOUNTED "/proc/mounts" @@ -117,6 +120,20 @@ platform_set_blocksize(int fd, char *path, int blocksize) } } +int +platform_get_blocksize(int fd, char *path) +{ + int blocksize; + + if (ioctl(fd, BLKSSZGET, &blocksize) < 0) { + fprintf(stderr, _("%s: warning - cannot get sector size " + "from block device %s: %s\n"), + progname, path, strerror(errno)); + blocksize = BBSIZE; + } + return blocksize; +} + void platform_flush_device(int fd) { diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index fc878be43..ca43d9942 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -1382,6 +1382,7 @@ main( (long long)dblocks, XFS_MIN_DATA_BLOCKS); usage(); } + if (loginternal && xi.logdev) { fprintf(stderr, _("can't have both external and internal logs\n")); @@ -1391,6 +1392,26 @@ main( _("data and log sector sizes must be equal for internal logs\n")); usage(); } + + if (xi.dbsize > sectorsize) { + fprintf(stderr, _( +"Warning: the data subvolume sector size %u is less than the sector size \n\ +reported by the device (%u).\n"), + sectorsize, xi.dbsize); + } + if (!loginternal && xi.lbsize > lsectorsize) { + fprintf(stderr, _( +"Warning: the log subvolume sector size %u is less than the sector size\n\ +reported by the device (%u).\n"), + lsectorsize, xi.lbsize); + } + if (rtsize && xi.rtsize > 0 && xi.rtbsize > sectorsize) { + fprintf(stderr, _( +"Warning: the realtime subvolume sector size %u is less than the sector size\n\ +reported by the device (%u).\n"), + sectorsize, xi.rtbsize); + } + if (dirversion == 1) i = max_trres_v1[sectorlog - XFS_MIN_SECTORSIZE_LOG] [blocklog - XFS_MIN_BLOCKSIZE_LOG] @@ -1807,7 +1828,6 @@ _("log stripe unit (%d bytes) is too large for kernel to handle (max 256k)\n"), /* * Align the logstart at stripe unit boundary. */ - if (lsunit && ((logstart % lsunit) != 0)) { logstart = fixup_log_stripe(mp, lsflag, logstart, agsize, lsunit, &logblocks, blocklog);