On Fri, 30 May 2008 10:52:23 +1000, Eric Sandeen <sandeen@xxxxxxxxxxx>
wrote:
Barry Naujok wrote:
I hope the subject is explanation enough :)
not really ;)
Hum, if I normally lock why do I not want to lock? Locking good?
Locking bad? Locking too slow? locking for what? Incoherency ok? Man
page updates? :)
Ok, I've reversed the logic, makes it much clearer.
So, with prefetch mode in xfs_repair, you need to lock the xfs_buf_t's
so the prefetch and processing threads play sensibily with them (ie.
avoiding simultaneous reads/writes - much like the kernel xfs_buf_t's).
If you disable prefetch, or the process is single threaded, there is
no need to use the locks.
So, this patch only locks the buffers if it's xfs_repair running without
the -P mode.
===========================================================================
xfsprogs/include/libxfs.h
===========================================================================
--- a/xfsprogs/include/libxfs.h 2008-05-30 11:00:44.000000000 +1000
+++ b/xfsprogs/include/libxfs.h 2008-05-30 10:55:15.561596557 +1000
@@ -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 */
===========================================================================
xfsprogs/libxfs/init.c
===========================================================================
--- a/xfsprogs/libxfs/init.c 2008-05-30 11:00:44.000000000 +1000
+++ b/xfsprogs/libxfs/init.c 2008-05-30 10:57:52.189289029 +1000
@@ -28,6 +28,8 @@ int libxfs_ihash_size; /* #buckets in i
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:
===========================================================================
xfsprogs/libxfs/rdwr.c
===========================================================================
--- a/xfsprogs/libxfs/rdwr.c 2008-05-30 11:00:44.000000000 +1000
+++ b/xfsprogs/libxfs/rdwr.c 2008-05-30 10:58:47.018181515 +1000
@@ -375,6 +375,8 @@ struct list_head lock_buf_list = {&lock_
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
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);
}
===========================================================================
xfsprogs/repair/init.c
===========================================================================
--- a/xfsprogs/repair/init.c 2008-05-30 11:00:44.000000000 +1000
+++ b/xfsprogs/repair/init.c 2008-05-30 10:59:50.217989698 +1000
@@ -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)
no_xfs_buf_t_lock_repair.patch
Description: Text Data
|