PERFORCE change 195352 for review
Ilya Putsikau
ilya at FreeBSD.org
Sun Jun 26 09:51:17 UTC 2011
http://p4web.freebsd.org/@@195352?ac=10
Change 195352 by ilya at ilya_triton2011 on 2011/06/26 09:50:46
Add fuse_lck_mtx_lock macros
Affected files ...
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse.h#9 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_device.c#8 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_internal.c#13 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_ipc.c#8 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vnops.c#25 edit
Differences ...
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse.h#9 (text+ko) ====
@@ -105,8 +105,8 @@
#if USE_FUSE_LOCK
extern struct mtx fuse_mtx;
-#define FUSE_LOCK() mtx_lock(&fuse_mtx)
-#define FUSE_UNLOCK() mtx_unlock(&fuse_mtx)
+#define FUSE_LOCK() fuse_lck_mtx_lock(fuse_mtx)
+#define FUSE_UNLOCK() fuse_lck_mtx_unlock(fuse_mtx)
#else
#define FUSE_LOCK()
#define FUSE_UNLOCK()
@@ -142,6 +142,10 @@
#define FUSE_DEBUG_IPC 0
#endif
+#ifndef FUSE_DEBUG_LOCK
+#define FUSE_DEBUG_LOCK 0
+#endif
+
#ifndef FUSE_DEBUG_VFSOPS
#define FUSE_DEBUG_VFSOPS 0
#endif
@@ -158,3 +162,19 @@
if (((cond))) { \
printf("%s: " fmt, __func__, ## __VA_ARGS__); \
} } while (0)
+
+#define fuse_lck_mtx_lock(mtx) do { \
+ DEBUGX(FUSE_DEBUG_LOCK, "0: lock(%s): %s@%d by %d\n", \
+ __STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
+ mtx_lock(&(mtx)); \
+ DEBUGX(FUSE_DEBUG_LOCK, "1: lock(%s): %s@%d by %d\n", \
+ __STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
+ } while (0)
+
+#define fuse_lck_mtx_unlock(mtx) do { \
+ DEBUGX(FUSE_DEBUG_LOCK, "0: unlock(%s): %s@%d by %d\n", \
+ __STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
+ mtx_unlock(&(mtx)); \
+ DEBUGX(FUSE_DEBUG_LOCK, "1: unlock(%s): %s@%d by %d\n", \
+ __STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
+ } while (0)
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_device.c#8 (text+ko) ====
@@ -100,19 +100,19 @@
*/
#if DO_GIANT_MANUALLY
- mtx_lock(&Giant);
+ fuse_lck_mtx_lock(Giant);
#endif
if (fuse_useco < 0) {
/* Module unload is going on */
#if DO_GIANT_MANUALLY
- mtx_unlock(&Giant);
+ fuse_lck_mtx_unlock(Giant);
#endif
DEBUG("caught in the middle of unload\n");
return (ENOENT);
}
#if DO_GIANT_MANUALLY && USE_FUSE_LOCK
fuse_useco++;
- mtx_unlock(&Giant);
+ fuse_lck_mtx_unlock(Giant);
#endif
if (dev->si_usecount > 1)
@@ -136,7 +136,7 @@
}
FUSE_UNLOCK();
#if DO_GIANT_MANUALLY && ! USE_FUSE_LOCK
- mtx_unlock(&Giant);
+ fuse_lck_mtx_unlock(Giant);
#endif
DEBUG("%s: device opened by thread %d.\n", dev->si_name, td->td_tid);
@@ -148,7 +148,7 @@
#if USE_FUSE_LOCK
fuse_useco--;
#else
- mtx_unlock(&Giant);
+ fuse_lck_mtx_unlock(Giant);
#endif
#endif
return (EBUSY);
@@ -160,7 +160,7 @@
struct fuse_data *data;
#if DO_GIANT_MANUALLY && ! USE_FUSE_LOCK
- mtx_lock(&Giant);
+ fuse_lck_mtx_lock(Giant);
#endif
FUSE_LOCK();
data = fuse_get_devdata(dev);
@@ -170,7 +170,7 @@
("fuse device is already closed upon close"));
fdata_set_dead(data);
data->dataflags &= ~FSESS_OPENED;
- mtx_lock(&data->aw_mtx);
+ fuse_lck_mtx_lock(data->aw_mtx);
/* wakup poll()ers */
selwakeuppri(&data->ks_rsel, PZERO + 1);
@@ -181,13 +181,13 @@
/* Don't let syscall handlers wait in vain */
while ((tick = fuse_aw_pop(data))) {
- mtx_lock(&tick->tk_aw_mtx);
+ fuse_lck_mtx_lock(tick->tk_aw_mtx);
fticket_set_answered(tick);
tick->tk_aw_errno = ENOTCONN;
wakeup(tick);
- mtx_unlock(&tick->tk_aw_mtx);
+ fuse_lck_mtx_unlock(tick->tk_aw_mtx);
}
- mtx_unlock(&data->aw_mtx);
+ fuse_lck_mtx_unlock(data->aw_mtx);
FUSE_UNLOCK();
goto out;
@@ -199,7 +199,7 @@
out:
#if DO_GIANT_MANUALLY && ! USE_FUSE_LOCK
- mtx_unlock(&Giant);
+ fuse_lck_mtx_unlock(Giant);
#endif
fuse_useco--;
@@ -216,12 +216,12 @@
data = fuse_get_devdata(dev);
if (events & (POLLIN | POLLRDNORM)) {
- mtx_lock(&data->ms_mtx);
+ fuse_lck_mtx_lock(data->ms_mtx);
if (fdata_get_dead(data) || STAILQ_FIRST(&data->ms_head))
revents |= events & (POLLIN | POLLRDNORM);
else
selrecord(td, &data->ks_rsel);
- mtx_unlock(&data->ms_mtx);
+ fuse_lck_mtx_unlock(data->ms_mtx);
}
if (events & (POLLOUT | POLLWRNORM)) {
@@ -250,11 +250,11 @@
DEBUG("fuse device being read on thread %d\n", uio->uio_td->td_tid);
- mtx_lock(&data->ms_mtx);
+ fuse_lck_mtx_lock(data->ms_mtx);
again:
if (fdata_get_dead(data)) {
DEBUG2G("we know early on that reader should be kicked so we don't wait for news\n");
- mtx_unlock(&data->ms_mtx);
+ fuse_lck_mtx_unlock(data->ms_mtx);
return (ENODEV);
}
@@ -262,13 +262,13 @@
/* check if we may block */
if (ioflag & O_NONBLOCK) {
/* get outa here soon */
- mtx_unlock(&data->ms_mtx);
+ fuse_lck_mtx_unlock(data->ms_mtx);
return (EAGAIN);
}
else {
err = msleep(data, &data->ms_mtx, PCATCH, "fu_msg", 0);
if (err != 0) {
- mtx_unlock(&data->ms_mtx);
+ fuse_lck_mtx_unlock(data->ms_mtx);
return (fdata_get_dead(data) ? ENODEV : err);
}
tick = fuse_ms_pop(data);
@@ -284,7 +284,7 @@
DEBUG("no message on thread #%d\n", uio->uio_td->td_tid);
goto again;
}
- mtx_unlock(&data->ms_mtx);
+ fuse_lck_mtx_unlock(data->ms_mtx);
if (fdata_get_dead(data)) {
/*
@@ -418,7 +418,7 @@
/* Pass stuff over to callback if there is one installed */
/* Looking for ticket with the unique id of header */
- mtx_lock(&data->aw_mtx);
+ fuse_lck_mtx_lock(data->aw_mtx);
TAILQ_FOREACH_SAFE(tick, &data->aw_head, tk_aw_link,
x_tick) {
DEBUG("bumped into callback #%llu\n",
@@ -429,7 +429,7 @@
break;
}
}
- mtx_unlock(&data->aw_mtx);
+ fuse_lck_mtx_unlock(data->aw_mtx);
if (found) {
if (tick->tk_aw_handler) {
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_internal.c#13 (text+ko) ====
@@ -621,10 +621,10 @@
fdata_set_dead(data);
}
- mtx_lock(&data->ticket_mtx);
+ fuse_lck_mtx_lock(data->ticket_mtx);
data->dataflags |= FSESS_INITED;
wakeup(&data->ticketer);
- mtx_unlock(&data->ticket_mtx);
+ fuse_lck_mtx_unlock(data->ticket_mtx);
return 0;
}
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_ipc.c#8 (text+ko) ====
@@ -197,7 +197,7 @@
int err = 0;
debug_printf("ftick=%p\n", ftick);
- mtx_lock(&ftick->tk_aw_mtx);
+ fuse_lck_mtx_lock(ftick->tk_aw_mtx);
if (fticket_answered(ftick)) {
goto out;
@@ -212,7 +212,7 @@
err = msleep(ftick, &ftick->tk_aw_mtx, PCATCH, "fu_ans", 0);
out:
- mtx_unlock(&ftick->tk_aw_mtx);
+ fuse_lck_mtx_unlock(ftick->tk_aw_mtx);
if (!(err || fticket_answered(ftick))) {
debug_printf("FUSE: requester was woken up but still no answer");
@@ -346,20 +346,20 @@
{
debug_printf("data=%p\n", data);
- mtx_lock(&data->ms_mtx);
+ fuse_lck_mtx_lock(data->ms_mtx);
if (fdata_get_dead(data)) {
- mtx_unlock(&data->ms_mtx);
+ fuse_lck_mtx_unlock(data->ms_mtx);
return;
}
data->dataflags |= FSESS_DEAD;
wakeup_one(data);
selwakeuppri(&data->ks_rsel, PZERO + 1);
- mtx_unlock(&data->ms_mtx);
+ fuse_lck_mtx_unlock(data->ms_mtx);
- mtx_lock(&data->ticket_mtx);
+ fuse_lck_mtx_lock(data->ticket_mtx);
wakeup(&data->ticketer);
- mtx_unlock(&data->ticket_mtx);
+ fuse_lck_mtx_unlock(data->ticket_mtx);
}
static __inline__
@@ -435,15 +435,15 @@
debug_printf("data=%p\n", data);
- mtx_lock(&data->ticket_mtx);
+ fuse_lck_mtx_lock(data->ticket_mtx);
if (data->freeticket_counter == 0) {
- mtx_unlock(&data->ticket_mtx);
+ fuse_lck_mtx_unlock(data->ticket_mtx);
ftick = fticket_alloc(data);
if (!ftick) {
panic("ticket allocation failed");
}
- mtx_lock(&data->ticket_mtx);
+ fuse_lck_mtx_lock(data->ticket_mtx);
fuse_push_allticks(ftick);
} else {
/* locked here */
@@ -457,7 +457,7 @@
err = msleep(&data->ticketer, &data->ticket_mtx, PCATCH | PDROP,
"fu_ini", 0);
} else {
- mtx_unlock(&data->ticket_mtx);
+ fuse_lck_mtx_unlock(data->ticket_mtx);
}
if (err) {
@@ -474,26 +474,26 @@
debug_printf("ftick=%p\n", ftick);
- mtx_lock(&ftick->tk_data->ticket_mtx);
+ fuse_lck_mtx_lock(ftick->tk_data->ticket_mtx);
if (fuse_max_freetickets >= 0 &&
fuse_max_freetickets <= ftick->tk_data->freeticket_counter) {
die = 1;
} else {
- mtx_unlock(&ftick->tk_data->ticket_mtx);
+ fuse_lck_mtx_unlock(ftick->tk_data->ticket_mtx);
fticket_refresh(ftick);
- mtx_lock(&ftick->tk_data->ticket_mtx);
+ fuse_lck_mtx_lock(ftick->tk_data->ticket_mtx);
}
/* locked here */
if (die) {
fuse_remove_allticks(ftick);
- mtx_unlock(&ftick->tk_data->ticket_mtx);
+ fuse_lck_mtx_unlock(ftick->tk_data->ticket_mtx);
fticket_destroy(ftick);
} else {
fuse_push_freeticks(ftick);
- mtx_unlock(&ftick->tk_data->ticket_mtx);
+ fuse_lck_mtx_unlock(ftick->tk_data->ticket_mtx);
}
}
@@ -518,9 +518,9 @@
ftick->tk_aw_handler = handler;
- mtx_lock(&ftick->tk_data->aw_mtx);
+ fuse_lck_mtx_lock(ftick->tk_data->aw_mtx);
fuse_aw_push(ftick);
- mtx_unlock(&ftick->tk_data->aw_mtx);
+ fuse_lck_mtx_unlock(ftick->tk_data->aw_mtx);
}
void
@@ -538,11 +538,11 @@
return;
}
- mtx_lock(&ftick->tk_data->ms_mtx);
+ fuse_lck_mtx_lock(ftick->tk_data->ms_mtx);
fuse_ms_push(ftick);
wakeup_one(ftick->tk_data);
selwakeuppri(&ftick->tk_data->ks_rsel, PZERO + 1);
- mtx_unlock(&ftick->tk_data->ms_mtx);
+ fuse_lck_mtx_unlock(ftick->tk_data->ms_mtx);
}
static int
@@ -752,7 +752,7 @@
err = fticket_pull(ftick, uio);
- mtx_lock(&ftick->tk_aw_mtx);
+ fuse_lck_mtx_lock(ftick->tk_aw_mtx);
if (fticket_answered(ftick)) {
/* The requester was interrupted and she set the "answered" flag
@@ -766,7 +766,7 @@
wakeup(ftick);
}
- mtx_unlock(&ftick->tk_aw_mtx);
+ fuse_lck_mtx_unlock(ftick->tk_aw_mtx);
if (dropflag) {
fuse_ticket_drop(ftick);
@@ -848,7 +848,7 @@
debug_printf("IPC: interrupted, err = %d\n", err);
- mtx_lock(&fdip->tick->tk_aw_mtx);
+ fuse_lck_mtx_lock(fdip->tick->tk_aw_mtx);
if (fticket_answered(fdip->tick)) {
/*
@@ -857,7 +857,7 @@
* So we drop the ticket and exit as usual.
*/
debug_printf("IPC: already answered\n");
- mtx_unlock(&fdip->tick->tk_aw_mtx);
+ fuse_lck_mtx_unlock(fdip->tick->tk_aw_mtx);
goto out;
} else {
/*
@@ -868,7 +868,7 @@
debug_printf("IPC: setting to answered\n");
age = fdip->tick->tk_age;
fticket_set_answered(fdip->tick);
- mtx_unlock(&fdip->tick->tk_aw_mtx);
+ fuse_lck_mtx_unlock(fdip->tick->tk_aw_mtx);
#ifndef DONT_TRY_HARD_PREVENT_IO_IN_VAIN
/*
* If we are willing to pay with one more locking, we
@@ -878,7 +878,7 @@
* won't even be called. (No guarantee though for
* being fast.)
*/
- mtx_lock(&fdip->tick->tk_data->aw_mtx);
+ fuse_lck_mtx_lock(fdip->tick->tk_data->aw_mtx);
TAILQ_FOREACH(tick, &fdip->tick->tk_data->aw_head, tk_aw_link) {
if (tick == fdip->tick) {
if (fdip->tick->tk_age == age) {
@@ -889,7 +889,7 @@
}
}
- mtx_unlock(&fdip->tick->tk_data->aw_mtx);
+ fuse_lck_mtx_unlock(fdip->tick->tk_data->aw_mtx);
#endif
return err;
}
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vnops.c#25 (text+ko) ====
@@ -1151,7 +1151,7 @@
if (!isdir && (fvdat->flag & FN_CREATING)) {
- mtx_lock(&fvdat->createlock);
+ fuse_lck_mtx_lock(fvdat->createlock);
if (fvdat->flag & FN_CREATING) { // check again
if (fvdat->creator == curthread->td_tid) {
@@ -1180,7 +1180,7 @@
fvdat->flag &= ~FN_CREATING;
- mtx_unlock(&fvdat->createlock);
+ fuse_lck_mtx_unlock(fvdat->createlock);
wakeup((caddr_t)&fvdat->creator); // wake up all
goto ok; /* return 0 */
} else {
@@ -1203,7 +1203,7 @@
}
}
} else {
- mtx_unlock(&fvdat->createlock);
+ fuse_lck_mtx_unlock(fvdat->createlock);
/* Can proceed from here. */
}
}
More information about the p4-projects
mailing list