From: Barry Naujok Date: Fri, 30 May 2008 04:31:27 +0000 (+0000) Subject: Only use xfs_buf_t locks when doing prefetched repair X-Git-Tag: v3.0.0~70 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d0572de5a4de7fe885b53758f4cfb3da84bd644a;p=thirdparty%2Fxfsprogs-dev.git Only use xfs_buf_t locks when doing prefetched repair Merge of master-melb:xfs-cmds:31256a by kenmcd. Add "usebuflock" field to xfs_init --- diff --git a/include/libxfs.h b/include/libxfs.h index 84d6ec6fb..f4286847c 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -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 */ diff --git a/libxfs/init.c b/libxfs/init.c index e7d645f2c..e31c26b41 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -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: diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 62937bfc7..8d84cd3f1 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -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); } diff --git a/man/man8/xfs_repair.8 b/man/man8/xfs_repair.8 index d6cecb86a..eb40ed280 100644 --- a/man/man8/xfs_repair.8 +++ b/man/man8/xfs_repair.8 @@ -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 diff --git a/repair/init.c b/repair/init.c index 63e9754ef..18298b64e 100644 --- a/repair/init.c +++ b/repair/init.c @@ -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)