mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org, aviro@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 17/17] FRV: Stop XFS from accessing sem count directly
Date: Fri, 6 Jan 2006 16:29:38 GMT	[thread overview]
Message-ID: <200601061629.k06GTcpH011394@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <dhowells1136564974@warthog.cambridge.redhat.com>

The attached patch stops the XFS from accessing the internals of a semaphore
directly. On the FRV arch, which XFS does does not work. This alternative
implementation was supplied by Al Viro.

If Ingo Molnar's mutexes are going to be accepted into the kernel, then this
patch should be dropped.

Signed-Off-By: David Howells <dhowells@redhat.com>
---
warthog>diffstat -p1 xfs-sema-2615.diff
 fs/xfs/linux-2.6/sema.h       |    5 ++++-
 fs/xfs/quota/xfs_dquot.h      |    4 ++--
 fs/xfs/quota/xfs_dquot_item.c |    4 ++--
 fs/xfs/xfs_iget.c             |    2 +-
 fs/xfs/xfs_inode.c            |    4 ++--
 fs/xfs/xfs_inode_item.c       |    6 +++---
 6 files changed, 14 insertions(+), 11 deletions(-)

diff -uNrp /warthog/kernels/linux-2.6.15/fs/xfs/linux-2.6/sema.h linux-2.6.15-frv/fs/xfs/linux-2.6/sema.h
--- /warthog/kernels/linux-2.6.15/fs/xfs/linux-2.6/sema.h	2006-01-04 12:39:36.000000000 +0000
+++ linux-2.6.15-frv/fs/xfs/linux-2.6/sema.h	2006-01-06 14:43:43.000000000 +0000
@@ -34,8 +34,11 @@ typedef struct semaphore sema_t;
 #define initnsema(sp, val, name)	sema_init(sp, val)
 #define psema(sp, b)			down(sp)
 #define vsema(sp)			up(sp)
-#define valusema(sp)			(atomic_read(&(sp)->count))
 #define freesema(sema)
+static inline int sem_is_locked(sema_t *sp)
+{
+	return down_trylock(sp) || (up(sp), 0);
+}
 
 /*
  * Map cpsema (try to get the sema) to down_trylock. We need to switch
diff -uNrp /warthog/kernels/linux-2.6.15/fs/xfs/quota/xfs_dquot.h linux-2.6.15-frv/fs/xfs/quota/xfs_dquot.h
--- /warthog/kernels/linux-2.6.15/fs/xfs/quota/xfs_dquot.h	2006-01-04 12:39:36.000000000 +0000
+++ linux-2.6.15-frv/fs/xfs/quota/xfs_dquot.h	2006-01-06 14:43:43.000000000 +0000
@@ -119,7 +119,7 @@ XFS_DQ_IS_LOCKED(xfs_dquot_t *dqp)
  */
 #define xfs_dqflock(dqp)	 { psema(&((dqp)->q_flock), PINOD | PRECALC);\
 				   (dqp)->dq_flags |= XFS_DQ_FLOCKED; }
-#define xfs_dqfunlock(dqp)	 { ASSERT(valusema(&((dqp)->q_flock)) <= 0); \
+#define xfs_dqfunlock(dqp)	 { ASSERT(sem_is_locked(&((dqp)->q_flock))); \
 				   vsema(&((dqp)->q_flock)); \
 				   (dqp)->dq_flags &= ~(XFS_DQ_FLOCKED); }
 
@@ -128,7 +128,7 @@ XFS_DQ_IS_LOCKED(xfs_dquot_t *dqp)
 #define XFS_DQ_PINUNLOCK(dqp, s)   mutex_spinunlock( \
 				     &(XFS_DQ_TO_QINF(dqp)->qi_pinlock), s)
 
-#define XFS_DQ_IS_FLUSH_LOCKED(dqp) (valusema(&((dqp)->q_flock)) <= 0)
+#define XFS_DQ_IS_FLUSH_LOCKED(dqp) (sem_is_locked(&((dqp)->q_flock)))
 #define XFS_DQ_IS_ON_FREELIST(dqp)  ((dqp)->dq_flnext != (dqp))
 #define XFS_DQ_IS_DIRTY(dqp)	((dqp)->dq_flags & XFS_DQ_DIRTY)
 #define XFS_QM_ISUDQ(dqp)	((dqp)->dq_flags & XFS_DQ_USER)
diff -uNrp /warthog/kernels/linux-2.6.15/fs/xfs/quota/xfs_dquot_item.c linux-2.6.15-frv/fs/xfs/quota/xfs_dquot_item.c
--- /warthog/kernels/linux-2.6.15/fs/xfs/quota/xfs_dquot_item.c	2006-01-04 12:39:36.000000000 +0000
+++ linux-2.6.15-frv/fs/xfs/quota/xfs_dquot_item.c	2006-01-06 14:43:43.000000000 +0000
@@ -246,7 +246,7 @@ xfs_qm_dquot_logitem_pushbuf(
 	 * inode flush completed and the inode was taken off the AIL.
 	 * So, just get out.
 	 */
-	if ((valusema(&(dqp->q_flock)) > 0)  ||
+	if (!sem_is_locked(&(dqp->q_flock))  ||
 	    ((qip->qli_item.li_flags & XFS_LI_IN_AIL) == 0)) {
 		qip->qli_pushbuf_flag = 0;
 		xfs_dqunlock(dqp);
@@ -259,7 +259,7 @@ xfs_qm_dquot_logitem_pushbuf(
 	if (bp != NULL) {
 		if (XFS_BUF_ISDELAYWRITE(bp)) {
 			dopush = ((qip->qli_item.li_flags & XFS_LI_IN_AIL) &&
-				  (valusema(&(dqp->q_flock)) <= 0));
+				  sem_is_locked(&(dqp->q_flock)));
 			qip->qli_pushbuf_flag = 0;
 			xfs_dqunlock(dqp);
 
diff -uNrp /warthog/kernels/linux-2.6.15/fs/xfs/xfs_iget.c linux-2.6.15-frv/fs/xfs/xfs_iget.c
--- /warthog/kernels/linux-2.6.15/fs/xfs/xfs_iget.c	2006-01-04 12:39:37.000000000 +0000
+++ linux-2.6.15-frv/fs/xfs/xfs_iget.c	2006-01-06 14:43:43.000000000 +0000
@@ -1041,6 +1041,6 @@ xfs_iflock_nowait(xfs_inode_t *ip)
 void
 xfs_ifunlock(xfs_inode_t *ip)
 {
-	ASSERT(valusema(&(ip->i_flock)) <= 0);
+	ASSERT(sem_is_locked(&(ip->i_flock)));
 	vsema(&(ip->i_flock));
 }
diff -uNrp /warthog/kernels/linux-2.6.15/fs/xfs/xfs_inode.c linux-2.6.15-frv/fs/xfs/xfs_inode.c
--- /warthog/kernels/linux-2.6.15/fs/xfs/xfs_inode.c	2006-01-04 12:39:37.000000000 +0000
+++ linux-2.6.15-frv/fs/xfs/xfs_inode.c	2006-01-06 14:43:43.000000000 +0000
@@ -3061,7 +3061,7 @@ xfs_iflush(
 	XFS_STATS_INC(xs_iflush_count);
 
 	ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE|MR_ACCESS));
-	ASSERT(valusema(&ip->i_flock) <= 0);
+	ASSERT(sem_is_locked(&(ip->i_flock)));
 	ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
 	       ip->i_d.di_nextents > ip->i_df.if_ext_max);
 
@@ -3319,7 +3319,7 @@ xfs_iflush_int(
 	SPLDECL(s);
 
 	ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE|MR_ACCESS));
-	ASSERT(valusema(&ip->i_flock) <= 0);
+	ASSERT(sem_is_locked(&(ip->i_flock)));
 	ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
 	       ip->i_d.di_nextents > ip->i_df.if_ext_max);
 
diff -uNrp /warthog/kernels/linux-2.6.15/fs/xfs/xfs_inode_item.c linux-2.6.15-frv/fs/xfs/xfs_inode_item.c
--- /warthog/kernels/linux-2.6.15/fs/xfs/xfs_inode_item.c	2006-01-04 12:39:37.000000000 +0000
+++ linux-2.6.15-frv/fs/xfs/xfs_inode_item.c	2006-01-06 14:43:43.000000000 +0000
@@ -789,7 +789,7 @@ xfs_inode_item_pushbuf(
 	 * inode flush completed and the inode was taken off the AIL.
 	 * So, just get out.
 	 */
-	if ((valusema(&(ip->i_flock)) > 0)  ||
+	if (!sem_is_locked(&(ip->i_flock)) ||
 	    ((iip->ili_item.li_flags & XFS_LI_IN_AIL) == 0)) {
 		iip->ili_pushbuf_flag = 0;
 		xfs_iunlock(ip, XFS_ILOCK_SHARED);
@@ -811,7 +811,7 @@ xfs_inode_item_pushbuf(
 			 * If not, we can flush it async.
 			 */
 			dopush = ((iip->ili_item.li_flags & XFS_LI_IN_AIL) &&
-				  (valusema(&(ip->i_flock)) <= 0));
+				  sem_is_locked(&(ip->i_flock)));
 			iip->ili_pushbuf_flag = 0;
 			xfs_iunlock(ip, XFS_ILOCK_SHARED);
 			xfs_buftrace("INODE ITEM PUSH", bp);
@@ -859,7 +859,7 @@ xfs_inode_item_push(
 	ip = iip->ili_inode;
 
 	ASSERT(ismrlocked(&(ip->i_lock), MR_ACCESS));
-	ASSERT(valusema(&(ip->i_flock)) <= 0);
+	ASSERT(sem_is_locked(&(ip->i_flock)));
 	/*
 	 * Since we were able to lock the inode's flush lock and
 	 * we found it on the AIL, the inode must be dirty.  This

  parent reply	other threads:[~2006-01-06 16:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-06 16:29 [PATCH 0/17] FRV: Permit compilation with allmodconfig David Howells
2006-01-06 16:29 ` [PATCH 3/17] FRV: Drop unsupported debugging features David Howells
2006-01-06 16:29 ` [PATCH 1/17] FRV: Suppress configuration of certain features for FRV David Howells
2006-01-06 16:29 ` [PATCH 2/17] FRV: Drop 8/16-bit xchg and cmpxchg David Howells
2006-01-06 16:29 ` [PATCH 4/17] FRV: Implement and export various things required by modules David Howells
2006-01-06 16:29 ` [PATCH 7/17] FRV: Add module support stubs David Howells
2006-01-06 16:29 ` [PATCH 8/17] FRV: Add pci_iomap David Howells
2006-01-06 16:29 ` [PATCH 10/17] FRV: Force serial driver inclusion David Howells
2006-01-06 16:29 ` [PATCH 5/17] FRV: Support module exception tables David Howells
2006-01-06 16:29 ` [PATCH 6/17] FRV: Supply various missing I/O access primitives David Howells
2006-01-06 16:29 ` [PATCH 9/17] FRV: Fix PCMCIA configuration David Howells
2006-01-06 16:29 ` [PATCH 12/17] FRV: Miscellaneous changes David Howells
2006-01-06 16:29 ` [PATCH 13/17] FRV: Fix uninitialised variable in atm nicstar driver David Howells
2006-01-06 16:29 ` [PATCH 15/17] FRV: Export __rcuref_hash David Howells
2006-01-06 16:59   ` Eric Dumazet
2006-01-06 16:29 ` [PATCH 14/17] FRV: Stop the IEEE1394 nodemanager from accessing sem count directly David Howells
2006-01-06 16:29 ` [PATCH 11/17] FRV: Make get_user macro cast pointers David Howells
2006-01-06 16:29 ` [PATCH 16/17] FRV: Fix uninitialised variable in serverworks driver David Howells
2006-01-06 16:29 ` David Howells [this message]
2006-01-06 17:18 ` [PATCH 0/17] FRV: Permit compilation with allmodconfig Jan Dittmer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200601061629.k06GTcpH011394@warthog.cambridge.redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=aviro@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®