linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: mutex can't be used by down_write_nest_lock()
@ 2016-02-27  0:25 Yang Shi
  2016-03-01  8:59 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Yang Shi @ 2016-02-27  0:25 UTC (permalink / raw)
  To: jaegeuk, cm224.lee, chao2.yu, tglx, rostedt, bigeasy
  Cc: linux-kernel, linux-f2fs-devel, linux-fsdevel, linux-rt-users,
	linaro-kernel, yang.shi

fsf2_lock_all() calls down_write_nest_lock() to acquire a rw_sem and check
a mutex, but down_write_nest_lock() is designed for two rw_sem accoring to the
comment in include/linux/rwsem.h. And, other than f2fs, it is just called in
mm/mmap.c with two rwsem.

So, it looks it is used wrongly by f2fs. And, it causes the below compile
warning on -rt kernel too.

In file included from fs/f2fs/xattr.c:25:0:
fs/f2fs/f2fs.h: In function 'f2fs_lock_all':
fs/f2fs/f2fs.h:962:34: warning: passing argument 2 of 'down_write_nest_lock' from incompatible pointer type [-Wincompatible-pointer-types]
  f2fs_down_write(&sbi->cp_rwsem, &sbi->cp_mutex);
                                  ^
fs/f2fs/f2fs.h:27:55: note: in definition of macro 'f2fs_down_write'
 #define f2fs_down_write(x, y) down_write_nest_lock(x, y)
                                                       ^
In file included from include/linux/rwsem.h:22:0,
                 from fs/f2fs/xattr.c:21:
include/linux/rwsem_rt.h:138:20: note: expected 'struct rw_semaphore *' but argument is of type 'struct mutex *'
 static inline void down_write_nest_lock(struct rw_semaphore *sem,

Signed-off-by: Yang Shi <yang.shi@linaro.org>
---
 fs/f2fs/f2fs.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index ff79054..af77c1a 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -25,7 +25,6 @@
 
 #ifdef CONFIG_F2FS_CHECK_FS
 #define f2fs_bug_on(sbi, condition)	BUG_ON(condition)
-#define f2fs_down_write(x, y)	down_write_nest_lock(x, y)
 #else
 #define f2fs_bug_on(sbi, condition)					\
 	do {								\
@@ -34,7 +33,6 @@
 			set_sbi_flag(sbi, SBI_NEED_FSCK);		\
 		}							\
 	} while (0)
-#define f2fs_down_write(x, y)	down_write(x)
 #endif
 
 /*
@@ -1006,7 +1004,7 @@ static inline void f2fs_unlock_op(struct f2fs_sb_info *sbi)
 
 static inline void f2fs_lock_all(struct f2fs_sb_info *sbi)
 {
-	f2fs_down_write(&sbi->cp_rwsem, &sbi->cp_mutex);
+	down_write(&sbi->cp_rwsem);
 }
 
 static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi)
-- 
2.0.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] f2fs: mutex can't be used by down_write_nest_lock()
  2016-02-27  0:25 [PATCH] f2fs: mutex can't be used by down_write_nest_lock() Yang Shi
@ 2016-03-01  8:59 ` Chao Yu
  2016-03-02 18:22   ` Jaegeuk Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2016-03-01  8:59 UTC (permalink / raw)
  To: 'Yang Shi', jaegeuk, cm224.lee, tglx, rostedt, bigeasy
  Cc: linux-kernel, linux-f2fs-devel, linux-fsdevel, linux-rt-users,
	linaro-kernel

Hi Yang,

> -----Original Message-----
> From: Yang Shi [mailto:yang.shi@linaro.org]
> Sent: Saturday, February 27, 2016 8:25 AM
> To: jaegeuk@kernel.org; cm224.lee@samsung.com; chao2.yu@samsung.com; tglx@linutronix.de;
> rostedt@goodmis.org; bigeasy@linutronix.de
> Cc: linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net;
> linux-fsdevel@vger.kernel.org; linux-rt-users@vger.kernel.org;
> linaro-kernel@lists.linaro.org; yang.shi@linaro.org
> Subject: [PATCH] f2fs: mutex can't be used by down_write_nest_lock()
> 
> fsf2_lock_all() calls down_write_nest_lock() to acquire a rw_sem and check

Nitpick, f2fs_lock_all().

Anyway, this patch looks good to me.

Reviewed-by: Chao Yu <chao2.yu@samsung.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] f2fs: mutex can't be used by down_write_nest_lock()
  2016-03-01  8:59 ` Chao Yu
@ 2016-03-02 18:22   ` Jaegeuk Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2016-03-02 18:22 UTC (permalink / raw)
  To: Chao Yu
  Cc: 'Yang Shi',
	cm224.lee, tglx, rostedt, bigeasy, linux-kernel,
	linux-f2fs-devel, linux-fsdevel, linux-rt-users, linaro-kernel

On Tue, Mar 01, 2016 at 04:59:39PM +0800, Chao Yu wrote:
> Hi Yang,
> 
> > -----Original Message-----
> > From: Yang Shi [mailto:yang.shi@linaro.org]
> > Sent: Saturday, February 27, 2016 8:25 AM
> > To: jaegeuk@kernel.org; cm224.lee@samsung.com; chao2.yu@samsung.com; tglx@linutronix.de;
> > rostedt@goodmis.org; bigeasy@linutronix.de
> > Cc: linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net;
> > linux-fsdevel@vger.kernel.org; linux-rt-users@vger.kernel.org;
> > linaro-kernel@lists.linaro.org; yang.shi@linaro.org
> > Subject: [PATCH] f2fs: mutex can't be used by down_write_nest_lock()
> > 
> > fsf2_lock_all() calls down_write_nest_lock() to acquire a rw_sem and check

Fixed, and merged. :)

> 
> Nitpick, f2fs_lock_all().
> 
> Anyway, this patch looks good to me.
> 
> Reviewed-by: Chao Yu <chao2.yu@samsung.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-02 18:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-27  0:25 [PATCH] f2fs: mutex can't be used by down_write_nest_lock() Yang Shi
2016-03-01  8:59 ` Chao Yu
2016-03-02 18:22   ` Jaegeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).