Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EFA93C433F5 for ; Tue, 22 Feb 2022 18:43:36 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nMa8O-0001yS-A7; Tue, 22 Feb 2022 18:43:34 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nMa8N-0001yL-Dd for linux-f2fs-devel@lists.sourceforge.net; Tue, 22 Feb 2022 18:43:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=+bXHFL77ezZEg+awCahATq+Oub/xwDc/cfPztbFrhd0=; b=ZO/pkHZc9G9Dm7meXf/DPYziSv NM1qLRhZqzn5Ry6BPzVAmPF27a+MqOZ0C74Hcp9PDXZ60U+2jT9wQLDyyWIHDYyE0L4wu61Vul0Id br9JJRMz5q2hkrm7A3ioGaLXgUmXOhpNi5Dt7ogclnbjNqc+YcthKeKaOC1e8jhGnA/w=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=+bXHFL77ezZEg+awCahATq+Oub/xwDc/cfPztbFrhd0=; b=Z Vdol8CycgPbiLu8su0+Jje8HMmqFFBdwRuAbefYO9ePweZTeMHDlSXcBunxSLO6EhWW0wKr2Qf7I8 TvM4MN9hmoh2y1367gQ69kNvePBOLk+0qPnJHa6xAzTplIvhILY749DHm1BU1Y19cTrELqVQS8JXI SdNwZWoF5DKzfJo8=; Received: from mail-pl1-f180.google.com ([209.85.214.180]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.94.2) id 1nMa8D-0001Qq-LH for linux-f2fs-devel@lists.sourceforge.net; Tue, 22 Feb 2022 18:43:30 +0000 Received: by mail-pl1-f180.google.com with SMTP id bd1so477088plb.13 for ; Tue, 22 Feb 2022 10:43:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+bXHFL77ezZEg+awCahATq+Oub/xwDc/cfPztbFrhd0=; b=sVSxsg2Qb1U8Ll3lSWhorFR6O7xIU2TrwZvB4tJWxhYNjR3mFPiQpeRaCOF/G0uG9m 3gR6P0ybP44fQhIhLjuBt8A06nuAxr1n+TfbNDvzwLjaCqYthyfaikx6A/lfVMv3lvey /jBhdSUp9GtoLN1FKWoAjwTrTV9IBrL4kJtn+qYZ5JzcysyINIymuas7cnE4UQjyDjL6 RTZCbB8jePpXNkOfpJshUdmA7CE8bwRehf7qLVdd1fC29tihYq9eADxNs/W6XPuItRsA 56Ytks1jiBncR4fS8zQqSoRckSd6u3/4BytPR1I1RKwBKhXkzDXhm+bOW9SF02VliESm hhLg== X-Gm-Message-State: AOAM532ikff7rXWwJf72k4+M1p3kFmvEflyFRc8Lihcvyd8af9egqu1i rZIkMCedu768AfojTVcz4o4= X-Google-Smtp-Source: ABdhPJydSJaXTujv64vjm/Z4VlO9b+0PnVgywp358B2Kpz2oi8dhAGga0bWCQ0Ml9mdN59eD1RqpKw== X-Received: by 2002:a17:902:7e8f:b0:14f:b09c:937a with SMTP id z15-20020a1709027e8f00b0014fb09c937amr11389064pla.0.1645555399967; Tue, 22 Feb 2022 10:43:19 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id o5sm17193329pfk.172.2022.02.22.10.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:43:19 -0800 (PST) From: Bart Van Assche To: Jaegeuk Kim Date: Tue, 22 Feb 2022 10:43:13 -0800 Message-Id: <20220222184313.6057-1-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Headers-End: 1nMa8D-0001Qq-LH Subject: [f2fs-dev] [PATCH] f2fs: Restore rwsem lockdep support X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: syzbot+0b9cadf5fc45a98a5083@syzkaller.appspotmail.com, Bart Van Assche , Tim Murray , linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Lockdep uses lock class keys in its analysis. init_rwsem() instantiates one lock class key with each init_rwsem() user as follows: #define init_rwsem(sem) \ do { \ static struct lock_class_key __key; \ \ __init_rwsem((sem), #sem, &__key); \ } while (0) Commit e4544b63a7ee ("f2fs: move f2fs to use reader-unfair rwsems") reduced the number of lock class keys from one per init_rwsem() user to one per file in which init_f2fs_rwsem() is used. This causes the same lock class key to be associated with multiple f2fs rwsems and also triggers a number of false positive lockdep deadlock reports. Fix this by again instantiating one lock class key with each init_f2fs_rwsem() caller. Cc: Tim Murray Reported-by: syzbot+0b9cadf5fc45a98a5083@syzkaller.appspotmail.com Fixes: e4544b63a7ee ("f2fs: move f2fs to use reader-unfair rwsems") Signed-off-by: Bart Van Assche --- fs/f2fs/f2fs.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index c9515c3c54fd..47bf9e30913f 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -2115,9 +2115,17 @@ static inline void clear_ckpt_flags(struct f2fs_sb_info *sbi, unsigned int f) spin_unlock_irqrestore(&sbi->cp_lock, flags); } -static inline void init_f2fs_rwsem(struct f2fs_rwsem *sem) +#define init_f2fs_rwsem(sem) \ +do { \ + static struct lock_class_key __key; \ + \ + __init_f2fs_rwsem((sem), #sem, &__key); \ +} while (0) + +static inline void __init_f2fs_rwsem(struct f2fs_rwsem *sem, + const char *sem_name, struct lock_class_key *key) { - init_rwsem(&sem->internal_rwsem); + __init_rwsem(&sem->internal_rwsem, sem_name, key); init_waitqueue_head(&sem->read_waiters); } _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel