]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Extract device sector size at mkfs time and issue warnings if the requested filesyste...
authorNathan Scott <nathans@sgi.com>
Wed, 21 May 2003 07:25:24 +0000 (07:25 +0000)
committerNathan Scott <nathans@sgi.com>
Wed, 21 May 2003 07:25:24 +0000 (07:25 +0000)
doc/CHANGES
include/libxfs.h
libxfs/darwin.c
libxfs/freebsd.c
libxfs/init.c
libxfs/init.h
libxfs/irix.c
libxfs/linux.c
mkfs/xfs_mkfs.c

index f45688b7a3ff31f6eee3009961017ca30c97b694..59e9c8009c8dda981ded25ae852b17e27be4e835 100644 (file)
@@ -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.
index ad72e106883154b5f5ee45571b0d9311f995dd7e..c2080ca01073e75cca479a404b4937b2d339c8d9 100644 (file)
@@ -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 */
index d7a8daede6ae98402d5bd55e0c142cadf9a5269b..6d6ac2d8b81f20e2245316615144daf5bf7685fb 100644 (file)
@@ -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
index b48b48e679c31860f67b6edb5f8154ad2334848e..d1a9d747d4a21d92da62e35f23b3953b5210fce6 100644 (file)
@@ -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)
 {
index 8ac8ad670996a250f09ec72d35afc4c5ca9db3bd..d94a7c9016a1146276a567e411aecca20d96c254 100644 (file)
@@ -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;
 }
 
index ec93874f18c433df0b32a9591ce7f2ae52e35514..363d8c3398cf8595c68e988d72f81b591e5180f5 100644 (file)
@@ -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 */
index d6782cc3e616d9fba00407c4f6224b51bf359327..f32be60b831c075b4be19565a7fb0c0f89bca13a 100644 (file)
@@ -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)
 {
index fd3be4705dd3d097b0d8f3235fe7f1732cd24691..068ec268e78cd39a5802b15378d48fffa81fa9b1 100644 (file)
@@ -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)
 {
index fc878be4353e214c0f7c5189091a2f0c2b977f86..ca43d9942a5f2373c25f4d81cd1dfd127c069280 100644 (file)
@@ -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);