aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2006-06-18 18:41:30 -0400
committerNathan Scott <nathans@sgi.com>2006-06-18 18:41:30 -0400
commit0d8fee3270f8a5e4bf95fbed3e81e21b57f8a5a0 (patch)
treee965874962259a2f16980f19a4e5c03ef635a86f /fs
parenta805bad5daae8d4f92ce46f467484d4867e996d4 (diff)
[XFS] Kill direct access to ->count in valusema(); all we ever use it for
is check if semaphore is actually locked, which can be trivially done in portable way. Code gets more reabable, while we are at it... SGI-PV: 953915 SGI-Modid: xfs-linux-melb:xfs-kern:26274a Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/linux-2.6/sema.h19
-rw-r--r--fs/xfs/quota/xfs_dquot.h4
-rw-r--r--fs/xfs/quota/xfs_dquot_item.c4
-rw-r--r--fs/xfs/xfs_iget.c2
-rw-r--r--fs/xfs/xfs_inode.c4
-rw-r--r--fs/xfs/xfs_inode_item.c6
6 files changed, 20 insertions, 19 deletions
diff --git a/fs/xfs/linux-2.6/sema.h b/fs/xfs/linux-2.6/sema.h
index 194a84490bd1..b25090094cca 100644
--- a/fs/xfs/linux-2.6/sema.h
+++ b/fs/xfs/linux-2.6/sema.h
@@ -34,20 +34,21 @@ typedef struct semaphore sema_t;
34#define initnsema(sp, val, name) sema_init(sp, val) 34#define initnsema(sp, val, name) sema_init(sp, val)
35#define psema(sp, b) down(sp) 35#define psema(sp, b) down(sp)
36#define vsema(sp) up(sp) 36#define vsema(sp) up(sp)
37#define valusema(sp) (atomic_read(&(sp)->count)) 37#define freesema(sema) do { } while (0)
38#define freesema(sema) 38
39static inline int issemalocked(sema_t *sp)
40{
41 return down_trylock(sp) || (up(sp), 0);
42}
39 43
40/* 44/*
41 * Map cpsema (try to get the sema) to down_trylock. We need to switch 45 * Map cpsema (try to get the sema) to down_trylock. We need to switch
42 * the return values since cpsema returns 1 (acquired) 0 (failed) and 46 * the return values since cpsema returns 1 (acquired) 0 (failed) and
43 * down_trylock returns the reverse 0 (acquired) 1 (failed). 47 * down_trylock returns the reverse 0 (acquired) 1 (failed).
44 */ 48 */
45 49static inline int cpsema(sema_t *sp)
46#define cpsema(sp) (down_trylock(sp) ? 0 : 1) 50{
47 51 return down_trylock(sp) ? 0 : 1;
48/* 52}
49 * Didn't do cvsema(sp). Not sure how to map this to up/down/...
50 * It does a vsema if the values is < 0 other wise nothing.
51 */
52 53
53#endif /* __XFS_SUPPORT_SEMA_H__ */ 54#endif /* __XFS_SUPPORT_SEMA_H__ */
diff --git a/fs/xfs/quota/xfs_dquot.h b/fs/xfs/quota/xfs_dquot.h
index c0c629663a5c..78d3ab95c5fd 100644
--- a/fs/xfs/quota/xfs_dquot.h
+++ b/fs/xfs/quota/xfs_dquot.h
@@ -119,7 +119,7 @@ XFS_DQ_IS_LOCKED(xfs_dquot_t *dqp)
119 */ 119 */
120#define xfs_dqflock(dqp) { psema(&((dqp)->q_flock), PINOD | PRECALC);\ 120#define xfs_dqflock(dqp) { psema(&((dqp)->q_flock), PINOD | PRECALC);\
121 (dqp)->dq_flags |= XFS_DQ_FLOCKED; } 121 (dqp)->dq_flags |= XFS_DQ_FLOCKED; }
122#define xfs_dqfunlock(dqp) { ASSERT(valusema(&((dqp)->q_flock)) <= 0); \ 122#define xfs_dqfunlock(dqp) { ASSERT(issemalocked(&((dqp)->q_flock))); \
123 vsema(&((dqp)->q_flock)); \ 123 vsema(&((dqp)->q_flock)); \
124 (dqp)->dq_flags &= ~(XFS_DQ_FLOCKED); } 124 (dqp)->dq_flags &= ~(XFS_DQ_FLOCKED); }
125 125
@@ -128,7 +128,7 @@ XFS_DQ_IS_LOCKED(xfs_dquot_t *dqp)
128#define XFS_DQ_PINUNLOCK(dqp, s) mutex_spinunlock( \ 128#define XFS_DQ_PINUNLOCK(dqp, s) mutex_spinunlock( \
129 &(XFS_DQ_TO_QINF(dqp)->qi_pinlock), s) 129 &(XFS_DQ_TO_QINF(dqp)->qi_pinlock), s)
130 130
131#define XFS_DQ_IS_FLUSH_LOCKED(dqp) (valusema(&((dqp)->q_flock)) <= 0) 131#define XFS_DQ_IS_FLUSH_LOCKED(dqp) (issemalocked(&((dqp)->q_flock)))
132#define XFS_DQ_IS_ON_FREELIST(dqp) ((dqp)->dq_flnext != (dqp)) 132#define XFS_DQ_IS_ON_FREELIST(dqp) ((dqp)->dq_flnext != (dqp))
133#define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY) 133#define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY)
134#define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER) 134#define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER)
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c
index 546f48af882a..21ad5a55e014 100644
--- a/fs/xfs/quota/xfs_dquot_item.c
+++ b/fs/xfs/quota/xfs_dquot_item.c
@@ -248,7 +248,7 @@ xfs_qm_dquot_logitem_pushbuf(
248 * inode flush completed and the inode was taken off the AIL. 248 * inode flush completed and the inode was taken off the AIL.
249 * So, just get out. 249 * So, just get out.
250 */ 250 */
251 if ((valusema(&(dqp->q_flock)) > 0) || 251 if (!issemalocked(&(dqp->q_flock)) ||
252 ((qip->qli_item.li_flags & XFS_LI_IN_AIL) == 0)) { 252 ((qip->qli_item.li_flags & XFS_LI_IN_AIL) == 0)) {
253 qip->qli_pushbuf_flag = 0; 253 qip->qli_pushbuf_flag = 0;
254 xfs_dqunlock(dqp); 254 xfs_dqunlock(dqp);
@@ -261,7 +261,7 @@ xfs_qm_dquot_logitem_pushbuf(
261 if (bp != NULL) { 261 if (bp != NULL) {
262 if (XFS_BUF_ISDELAYWRITE(bp)) { 262 if (XFS_BUF_ISDELAYWRITE(bp)) {
263 dopush = ((qip->qli_item.li_flags & XFS_LI_IN_AIL) && 263 dopush = ((qip->qli_item.li_flags & XFS_LI_IN_AIL) &&
264 (valusema(&(dqp->q_flock)) <= 0)); 264 issemalocked(&(dqp->q_flock)));
265 qip->qli_pushbuf_flag = 0; 265 qip->qli_pushbuf_flag = 0;
266 xfs_dqunlock(dqp); 266 xfs_dqunlock(dqp);
267 267
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index da3c94c230db..7894b72a7177 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -1031,6 +1031,6 @@ xfs_iflock_nowait(xfs_inode_t *ip)
1031void 1031void
1032xfs_ifunlock(xfs_inode_t *ip) 1032xfs_ifunlock(xfs_inode_t *ip)
1033{ 1033{
1034 ASSERT(valusema(&(ip->i_flock)) <= 0); 1034 ASSERT(issemalocked(&(ip->i_flock)));
1035 vsema(&(ip->i_flock)); 1035 vsema(&(ip->i_flock));
1036} 1036}
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 9af9e32a6a16..e799f0d00873 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3015,7 +3015,7 @@ xfs_iflush(
3015 XFS_STATS_INC(xs_iflush_count); 3015 XFS_STATS_INC(xs_iflush_count);
3016 3016
3017 ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE|MR_ACCESS)); 3017 ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE|MR_ACCESS));
3018 ASSERT(valusema(&ip->i_flock) <= 0); 3018 ASSERT(issemalocked(&(ip->i_flock)));
3019 ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || 3019 ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
3020 ip->i_d.di_nextents > ip->i_df.if_ext_max); 3020 ip->i_d.di_nextents > ip->i_df.if_ext_max);
3021 3021
@@ -3273,7 +3273,7 @@ xfs_iflush_int(
3273 SPLDECL(s); 3273 SPLDECL(s);
3274 3274
3275 ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE|MR_ACCESS)); 3275 ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE|MR_ACCESS));
3276 ASSERT(valusema(&ip->i_flock) <= 0); 3276 ASSERT(issemalocked(&(ip->i_flock)));
3277 ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || 3277 ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
3278 ip->i_d.di_nextents > ip->i_df.if_ext_max); 3278 ip->i_d.di_nextents > ip->i_df.if_ext_max);
3279 3279
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index cd65a565b4fe..2caa91b89714 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -794,7 +794,7 @@ xfs_inode_item_pushbuf(
794 * inode flush completed and the inode was taken off the AIL. 794 * inode flush completed and the inode was taken off the AIL.
795 * So, just get out. 795 * So, just get out.
796 */ 796 */
797 if ((valusema(&(ip->i_flock)) > 0) || 797 if (!issemalocked(&(ip->i_flock)) ||
798 ((iip->ili_item.li_flags & XFS_LI_IN_AIL) == 0)) { 798 ((iip->ili_item.li_flags & XFS_LI_IN_AIL) == 0)) {
799 iip->ili_pushbuf_flag = 0; 799 iip->ili_pushbuf_flag = 0;
800 xfs_iunlock(ip, XFS_ILOCK_SHARED); 800 xfs_iunlock(ip, XFS_ILOCK_SHARED);
@@ -816,7 +816,7 @@ xfs_inode_item_pushbuf(
816 * If not, we can flush it async. 816 * If not, we can flush it async.
817 */ 817 */
818 dopush = ((iip->ili_item.li_flags & XFS_LI_IN_AIL) && 818 dopush = ((iip->ili_item.li_flags & XFS_LI_IN_AIL) &&
819 (valusema(&(ip->i_flock)) <= 0)); 819 issemalocked(&(ip->i_flock)));
820 iip->ili_pushbuf_flag = 0; 820 iip->ili_pushbuf_flag = 0;
821 xfs_iunlock(ip, XFS_ILOCK_SHARED); 821 xfs_iunlock(ip, XFS_ILOCK_SHARED);
822 xfs_buftrace("INODE ITEM PUSH", bp); 822 xfs_buftrace("INODE ITEM PUSH", bp);
@@ -864,7 +864,7 @@ xfs_inode_item_push(
864 ip = iip->ili_inode; 864 ip = iip->ili_inode;
865 865
866 ASSERT(ismrlocked(&(ip->i_lock), MR_ACCESS)); 866 ASSERT(ismrlocked(&(ip->i_lock), MR_ACCESS));
867 ASSERT(valusema(&(ip->i_flock)) <= 0); 867 ASSERT(issemalocked(&(ip->i_flock)));
868 /* 868 /*
869 * Since we were able to lock the inode's flush lock and 869 * Since we were able to lock the inode's flush lock and
870 * we found it on the AIL, the inode must be dirty. This 870 * we found it on the AIL, the inode must be dirty. This