]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Only use xfs_buf_t locks when doing prefetched repair
authorBarry Naujok <bnaujok@sgi.com>
Fri, 30 May 2008 04:31:27 +0000 (04:31 +0000)
committerBarry Naujok <bnaujok@sgi.com>
Fri, 30 May 2008 04:31:27 +0000 (04:31 +0000)
Merge of master-melb:xfs-cmds:31256a by kenmcd.

  Add "usebuflock" field to xfs_init

include/libxfs.h
libxfs/init.c
libxfs/rdwr.c
man/man8/xfs_repair.8
repair/init.c

index 84d6ec6fbf738a17e9a3a0627a22df77d428b96d..f4286847c752d9870862f059f6fbd42bac3b4e91 100644 (file)
@@ -69,11 +69,14 @@ typedef struct {
        char            *rtname;        /* pathname of realtime "subvolume" */
        int             isreadonly;     /* filesystem is only read in applic */
        int             isdirect;       /* we can attempt to use direct I/O */
-       int             disfile;        /* data "subvolume" is a regular file */        int             dcreat;         /* try to create data subvolume */
+       int             disfile;        /* data "subvolume" is a regular file */
+       int             dcreat;         /* try to create data subvolume */
        int             lisfile;        /* log "subvolume" is a regular file */
        int             lcreat;         /* try to create log subvolume */
-       int             risfile;        /* realtime "subvolume" is a reg file */        int             rcreat;         /* try to create realtime subvolume */
+       int             risfile;        /* realtime "subvolume" is a reg file */
+       int             rcreat;         /* try to create realtime subvolume */
        int             setblksize;     /* attempt to set device blksize */
+       int             usebuflock;     /* lock xfs_buf_t's - for MT usage */
                                /* output results */
        dev_t           ddev;           /* device for data subvolume */
        dev_t           logdev;         /* device for log subvolume */
index e7d645f2c95b0dfa035d319dff11d26b80e0d733..e31c26b414d099a8565f8c1e7bb3ec135fc4d51d 100644 (file)
@@ -28,6 +28,8 @@ int libxfs_ihash_size;                /* #buckets in icache */
 struct cache *libxfs_bcache;   /* global buffer cache */
 int libxfs_bhash_size;         /* #buckets in bcache */
 
+int    use_xfs_buf_lock;       /* global flag: use xfs_buf_t locks for MT */
+
 static void manage_zones(int); /* setup global zones */
 
 /*
@@ -335,6 +337,7 @@ libxfs_init(libxfs_init_t *a)
        if (!libxfs_bhash_size)
                libxfs_bhash_size = LIBXFS_BHASHSIZE(sbp);
        libxfs_bcache = cache_init(libxfs_bhash_size, &libxfs_bcache_operations);
+       use_xfs_buf_lock = a->usebuflock;
        manage_zones(0);
        rval = 1;
 done:
index 62937bfc77c74c0b62840872dd6bac9805110419..8d84cd3f1deb142c593fe6da835de1e9bf25314d 100644 (file)
@@ -375,6 +375,8 @@ struct list_head    lock_buf_list = {&lock_buf_list, &lock_buf_list};
 int                    lock_buf_count = 0;
 #endif
 
+extern int     use_xfs_buf_lock;
+
 xfs_buf_t *
 libxfs_getbuf(dev_t device, xfs_daddr_t blkno, int len)
 {
@@ -388,7 +390,8 @@ libxfs_getbuf(dev_t device, xfs_daddr_t blkno, int len)
 
        miss = cache_node_get(libxfs_bcache, &key, (struct cache_node **)&bp);
        if (bp) {
-               pthread_mutex_lock(&bp->b_lock);
+               if (use_xfs_buf_lock)
+                       pthread_mutex_lock(&bp->b_lock);
                cache_node_set_priority(libxfs_bcache, (struct cache_node *)bp,
                        cache_node_get_priority((struct cache_node *)bp) - 4);
 #ifdef XFS_BUF_TRACING
@@ -417,7 +420,8 @@ libxfs_putbuf(xfs_buf_t *bp)
        list_del_init(&bp->b_lock_list);
        pthread_mutex_unlock(&libxfs_bcache->c_mutex);
 #endif
-       pthread_mutex_unlock(&bp->b_lock);
+       if (use_xfs_buf_lock)
+               pthread_mutex_unlock(&bp->b_lock);
        cache_node_put((struct cache_node *)bp);
 }
 
index d6cecb86a9cbed2a02f768af83aa23fc13081d38..eb40ed28038d9a41efc02073b3771abf2cd436c1 100644 (file)
@@ -91,6 +91,14 @@ No modify mode. Specifies that
 should not modify the filesystem but should only scan the
 filesystem and indicate what repairs would have been made.
 .TP
+.B \-P
+Disable prefetching of inode and directory blocks. Use this option if
+you find
+.B xfs_repair
+gets stuck and stops proceeding. Interrupting a stuck
+.B xfs_repair
+is safe.
+.TP
 .BI \-m " maxmem"
 Specifies the approximate maximum amount of memory, in megabytes, to use for
 .BR xfs_repair .
@@ -146,9 +154,6 @@ Modify reporting interval. During long runs
 outputs its progress every 15 minutes. Reporting is only activated when
 ag_stride is enabled.
 .TP
-.B \-P
-Disable prefetching of inode and directory blocks.
-.TP
 .B \-v
 Verbose output.
 .TP
index 63e9754ef579623ac96bf3192f0d43ab4fde3e3c..18298b64e83f2b353cd2f24dabc9cf566ecb4ed3 100644 (file)
@@ -135,6 +135,7 @@ xfs_init(libxfs_init_t *args)
                /* XXX assume data file also means rt file */
        }
 
+       args->usebuflock = do_prefetch;
        args->setblksize = !dangerously;
        args->isdirect = LIBXFS_DIRECT;
        if (no_modify)