Skip to content

Commit 794ee1b

Browse files
jessorensenIngo Molnar
authored andcommitted
[PATCH] mutex subsystem, semaphore to mutex: XFS
This patch switches XFS over to use the new mutex code directly as opposed to the previous workaround patch I posted earlier that avoided the namespace clash by forcing it back to semaphores. This falls in the 'works for me<tm>' category. Signed-off-by: Jes Sorensen <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent de5097c commit 794ee1b

File tree

10 files changed

+22
-26
lines changed

10 files changed

+22
-26
lines changed

fs/xfs/linux-2.6/mutex.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define __XFS_SUPPORT_MUTEX_H__
2020

2121
#include <linux/spinlock.h>
22-
#include <asm/semaphore.h>
22+
#include <linux/mutex.h>
2323

2424
/*
2525
* Map the mutex'es from IRIX to Linux semaphores.
@@ -28,12 +28,8 @@
2828
* callers.
2929
*/
3030
#define MUTEX_DEFAULT 0x0
31-
typedef struct semaphore mutex_t;
3231

33-
#define mutex_init(lock, type, name) sema_init(lock, 1)
34-
#define mutex_destroy(lock) sema_init(lock, -99)
35-
#define mutex_lock(lock, num) down(lock)
36-
#define mutex_trylock(lock) (down_trylock(lock) ? 0 : 1)
37-
#define mutex_unlock(lock) up(lock)
32+
typedef struct mutex mutex_t;
33+
//#define mutex_destroy(lock) do{}while(0)
3834

3935
#endif /* __XFS_SUPPORT_MUTEX_H__ */

fs/xfs/quota/xfs_dquot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ xfs_qm_dqinit(
104104
*/
105105
if (brandnewdquot) {
106106
dqp->dq_flnext = dqp->dq_flprev = dqp;
107-
mutex_init(&dqp->q_qlock, MUTEX_DEFAULT, "xdq");
107+
mutex_init(&dqp->q_qlock);
108108
initnsema(&dqp->q_flock, 1, "fdq");
109109
sv_init(&dqp->q_pinwait, SV_DEFAULT, "pdq");
110110

@@ -1382,7 +1382,7 @@ void
13821382
xfs_dqlock(
13831383
xfs_dquot_t *dqp)
13841384
{
1385-
mutex_lock(&(dqp->q_qlock), PINOD);
1385+
mutex_lock(&(dqp->q_qlock));
13861386
}
13871387

13881388
void

fs/xfs/quota/xfs_qm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ xfs_Gqm_init(void)
167167
xqm->qm_dqfree_ratio = XFS_QM_DQFREE_RATIO;
168168
xqm->qm_nrefs = 0;
169169
#ifdef DEBUG
170-
mutex_init(&qcheck_lock, MUTEX_DEFAULT, "qchk");
170+
xfs_mutex_init(&qcheck_lock, MUTEX_DEFAULT, "qchk");
171171
#endif
172172
return xqm;
173173
}
@@ -1166,7 +1166,7 @@ xfs_qm_init_quotainfo(
11661166
qinf->qi_dqreclaims = 0;
11671167

11681168
/* mutex used to serialize quotaoffs */
1169-
mutex_init(&qinf->qi_quotaofflock, MUTEX_DEFAULT, "qoff");
1169+
mutex_init(&qinf->qi_quotaofflock);
11701170

11711171
/* Precalc some constants */
11721172
qinf->qi_dqchunklen = XFS_FSB_TO_BB(mp, XFS_DQUOT_CLUSTER_SIZE_FSB);
@@ -1285,7 +1285,7 @@ xfs_qm_list_init(
12851285
char *str,
12861286
int n)
12871287
{
1288-
mutex_init(&list->qh_lock, MUTEX_DEFAULT, str);
1288+
mutex_init(&list->qh_lock);
12891289
list->qh_next = NULL;
12901290
list->qh_version = 0;
12911291
list->qh_nelems = 0;
@@ -2762,7 +2762,7 @@ STATIC void
27622762
xfs_qm_freelist_init(xfs_frlist_t *ql)
27632763
{
27642764
ql->qh_next = ql->qh_prev = (xfs_dquot_t *) ql;
2765-
mutex_init(&ql->qh_lock, MUTEX_DEFAULT, "dqf");
2765+
mutex_init(&ql->qh_lock);
27662766
ql->qh_version = 0;
27672767
ql->qh_nelems = 0;
27682768
}
@@ -2772,7 +2772,7 @@ xfs_qm_freelist_destroy(xfs_frlist_t *ql)
27722772
{
27732773
xfs_dquot_t *dqp, *nextdqp;
27742774

2775-
mutex_lock(&ql->qh_lock, PINOD);
2775+
mutex_lock(&ql->qh_lock);
27762776
for (dqp = ql->qh_next;
27772777
dqp != (xfs_dquot_t *)ql; ) {
27782778
xfs_dqlock(dqp);

fs/xfs/quota/xfs_qm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ typedef struct xfs_dquot_acct {
165165
#define XFS_QM_IWARNLIMIT 5
166166
#define XFS_QM_RTBWARNLIMIT 5
167167

168-
#define XFS_QM_LOCK(xqm) (mutex_lock(&xqm##_lock, PINOD))
168+
#define XFS_QM_LOCK(xqm) (mutex_lock(&xqm##_lock))
169169
#define XFS_QM_UNLOCK(xqm) (mutex_unlock(&xqm##_lock))
170170
#define XFS_QM_HOLD(xqm) ((xqm)->qm_nrefs++)
171171
#define XFS_QM_RELE(xqm) ((xqm)->qm_nrefs--)

fs/xfs/quota/xfs_qm_bhv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ xfs_qm_init(void)
363363
KERN_INFO "SGI XFS Quota Management subsystem\n";
364364

365365
printk(message);
366-
mutex_init(&xfs_Gqm_lock, MUTEX_DEFAULT, "xfs_qmlock");
366+
mutex_init(&xfs_Gqm_lock);
367367
vfs_bhv_set_custom(&xfs_qmops, &xfs_qmcore_xfs);
368368
xfs_qm_init_procfs();
369369
}

fs/xfs/quota/xfs_qm_syscalls.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ xfs_qm_scall_quotaoff(
233233
*/
234234
ASSERT(mp->m_quotainfo);
235235
if (mp->m_quotainfo)
236-
mutex_lock(&(XFS_QI_QOFFLOCK(mp)), PINOD);
236+
mutex_lock(&(XFS_QI_QOFFLOCK(mp)));
237237

238238
ASSERT(mp->m_quotainfo);
239239

@@ -508,7 +508,7 @@ xfs_qm_scall_quotaon(
508508
/*
509509
* Switch on quota enforcement in core.
510510
*/
511-
mutex_lock(&(XFS_QI_QOFFLOCK(mp)), PINOD);
511+
mutex_lock(&(XFS_QI_QOFFLOCK(mp)));
512512
mp->m_qflags |= (flags & XFS_ALL_QUOTA_ENFD);
513513
mutex_unlock(&(XFS_QI_QOFFLOCK(mp)));
514514

@@ -617,7 +617,7 @@ xfs_qm_scall_setqlim(
617617
* a quotaoff from happening). (XXXThis doesn't currently happen
618618
* because we take the vfslock before calling xfs_qm_sysent).
619619
*/
620-
mutex_lock(&(XFS_QI_QOFFLOCK(mp)), PINOD);
620+
mutex_lock(&(XFS_QI_QOFFLOCK(mp)));
621621

622622
/*
623623
* Get the dquot (locked), and join it to the transaction.
@@ -1426,7 +1426,7 @@ xfs_qm_internalqcheck(
14261426
xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE | XFS_LOG_SYNC);
14271427
XFS_bflush(mp->m_ddev_targp);
14281428

1429-
mutex_lock(&qcheck_lock, PINOD);
1429+
mutex_lock(&qcheck_lock);
14301430
/* There should be absolutely no quota activity while this
14311431
is going on. */
14321432
qmtest_udqtab = kmem_zalloc(qmtest_hashmask *

fs/xfs/quota/xfs_quota_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#define XFS_QI_MPLNEXT(mp) ((mp)->m_quotainfo->qi_dqlist.qh_next)
5252
#define XFS_QI_MPLNDQUOTS(mp) ((mp)->m_quotainfo->qi_dqlist.qh_nelems)
5353

54-
#define XQMLCK(h) (mutex_lock(&((h)->qh_lock), PINOD))
54+
#define XQMLCK(h) (mutex_lock(&((h)->qh_lock)))
5555
#define XQMUNLCK(h) (mutex_unlock(&((h)->qh_lock)))
5656
#ifdef DEBUG
5757
struct xfs_dqhash;

fs/xfs/support/uuid.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static uuid_t *uuid_table;
2424
void
2525
uuid_init(void)
2626
{
27-
mutex_init(&uuid_monitor, MUTEX_DEFAULT, "uuid_monitor");
27+
mutex_init(&uuid_monitor);
2828
}
2929

3030
/*
@@ -94,7 +94,7 @@ uuid_table_insert(uuid_t *uuid)
9494
{
9595
int i, hole;
9696

97-
mutex_lock(&uuid_monitor, PVFS);
97+
mutex_lock(&uuid_monitor);
9898
for (i = 0, hole = -1; i < uuid_table_size; i++) {
9999
if (uuid_is_nil(&uuid_table[i])) {
100100
hole = i;
@@ -122,7 +122,7 @@ uuid_table_remove(uuid_t *uuid)
122122
{
123123
int i;
124124

125-
mutex_lock(&uuid_monitor, PVFS);
125+
mutex_lock(&uuid_monitor);
126126
for (i = 0; i < uuid_table_size; i++) {
127127
if (uuid_is_nil(&uuid_table[i]))
128128
continue;

fs/xfs/xfs_mount.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ xfs_mount_init(void)
117117

118118
AIL_LOCKINIT(&mp->m_ail_lock, "xfs_ail");
119119
spinlock_init(&mp->m_sb_lock, "xfs_sb");
120-
mutex_init(&mp->m_ilock, MUTEX_DEFAULT, "xfs_ilock");
120+
mutex_init(&mp->m_ilock);
121121
initnsema(&mp->m_growlock, 1, "xfs_grow");
122122
/*
123123
* Initialize the AIL.

fs/xfs/xfs_mount.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ typedef struct xfs_mod_sb {
533533
int msb_delta; /* Change to make to specified field */
534534
} xfs_mod_sb_t;
535535

536-
#define XFS_MOUNT_ILOCK(mp) mutex_lock(&((mp)->m_ilock), PINOD)
536+
#define XFS_MOUNT_ILOCK(mp) mutex_lock(&((mp)->m_ilock))
537537
#define XFS_MOUNT_IUNLOCK(mp) mutex_unlock(&((mp)->m_ilock))
538538
#define XFS_SB_LOCK(mp) mutex_spinlock(&(mp)->m_sb_lock)
539539
#define XFS_SB_UNLOCK(mp,s) mutex_spinunlock(&(mp)->m_sb_lock,(s))

0 commit comments

Comments
 (0)