Skip to contentSkip to conversation

f2fs: mutex can't be used by down_write_nest_lock()

PATCH In review Yang Shi 3 participants 3 messages Feb 27, 2016 – Mar 2, 2016

Subsystems (2)
lore
Share & tools
lore

Yang Shi

author
#0 lore raw

PATCH 1/1 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 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,

---
 fs/f2fs/f2fs.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/f2fs/f2fs.h +1 -3
index ff79054..af77c1a 100644
@@ -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)
Signature · 1 line
2.0.2
Reviewed-by on v1 1/1
#1 lore raw

Hi Yang,

Quoted 11 lines

-----Original Message-----
From: Yang Shi [mailto:[email protected]]
Sent: Saturday, February 27, 2016 8:25 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
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.

maintainer
#2 lore raw
Quoted 13 lines · Chao Yu

Hi Yang,

Quoted 11 lines

-----Original Message-----
From: Yang Shi [mailto:[email protected]]
Sent: Saturday, February 27, 2016 8:25 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
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. :)

Quoted 6 lines

Nitpick, f2fs_lock_all().

Anyway, this patch looks good to me.