From patchwork Sat Feb 27 00:25:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 63137 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp152916lbc; Fri, 26 Feb 2016 16:48:58 -0800 (PST) X-Received: by 10.98.10.65 with SMTP id s62mr6130500pfi.119.1456534138409; Fri, 26 Feb 2016 16:48:58 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zv5si23193078pac.220.2016.02.26.16.48.57; Fri, 26 Feb 2016 16:48:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755876AbcB0Asw (ORCPT + 30 others); Fri, 26 Feb 2016 19:48:52 -0500 Received: from mail-pf0-f170.google.com ([209.85.192.170]:35989 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752617AbcB0Asu (ORCPT ); Fri, 26 Feb 2016 19:48:50 -0500 Received: by mail-pf0-f170.google.com with SMTP id e127so60707484pfe.3 for ; Fri, 26 Feb 2016 16:48:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=3F726c1kN0f3DR1w5GScy4egVt0H4w4UaYxI9r7eIe8=; b=MX6pnD3VvxXaeKS+0Sx3V6B8EOgsL0JTAnndoR4SxRxTN5H1rM9qdw2DEsAmWxjn9V P5tlk1K0YdnXx1kM6t8RO6GGXlSuAH5U/WGLnqx9mBwpMrU07w6tjXmQkiXj7I70Z8M/ XH5GpnTKnSLlAnBN98PxRqvUkyjjKQb6kP+Mc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3F726c1kN0f3DR1w5GScy4egVt0H4w4UaYxI9r7eIe8=; b=XqVWAKMtffw5QNj3JtIhxIozhYIbYfc7G1ZDFtJpcZ5eJy0KmCyRFg4eNOdniFcZJk GDUKJ4mPC6n2UdJdr6WkUkgzWZEhrRFkZE3iLLSFnpXmPzuUgbaVdhfvECqku20eQmzE ySukvsBNFSeOBE0wWyLiB+KXFancSha2+YnAs12dOUbV4lpUgwCswL7kg7a0w29zfzQT 7FIW6Ci60x+IOlMoTdRxLTN35XqVDow/EyndU9MF44EAVhoUH50DY2uEo0wnmctTStvc CyhgK4RxoelXaZ/g8wKU+ruzZiOhxGoqZUVI/+WfMLazjQ5PsbcrKE1zNJNSEaL6c+Ml aHEA== X-Gm-Message-State: AD7BkJJoxNDOpODxqv+4bXV9uMNY0zmlF9t0Q2NkGxDCTDk2avqBtHZapuLTkIb8omT6BEvB X-Received: by 10.98.67.67 with SMTP id q64mr6323740pfa.44.1456534129801; Fri, 26 Feb 2016 16:48:49 -0800 (PST) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id o17sm21846467pfj.50.2016.02.26.16.48.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Feb 2016 16:48:49 -0800 (PST) From: Yang Shi 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() Date: Fri, 26 Feb 2016 16:25:25 -0800 Message-Id: <1456532725-4126-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/f2fs/f2fs.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.0.2 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)