From patchwork Fri Oct 27 16:23:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13438631 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3145938F86 for ; Fri, 27 Oct 2023 16:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="SIKPOSEi"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="8xCkyzkJ" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DB8B1A1 for ; Fri, 27 Oct 2023 09:23:45 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CF4361FEF5; Fri, 27 Oct 2023 16:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1698423823; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pHMG5d4SUaL3ruGrEo76lgOLitJ/3Da+PIxSgbLeusY=; b=SIKPOSEiZgBz4I/O4ey8mWQ2vkmjF8uwIrv3MzK8vIb52p9RFmo3679SkzVNzIZ7AarMzU qw9KtboAeEVFvJY7rYlTO65YB+mEiSKVo3ycgVrvC5Sc1KbmwhZ5Gh/xCKN6x9ocMTT6FA NE7skRiw+uiNrtWhbR5wEQTsKEBSEfA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1698423823; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pHMG5d4SUaL3ruGrEo76lgOLitJ/3Da+PIxSgbLeusY=; b=8xCkyzkJnIKAwSEVEGZ3l/VvnQ76xoZ+tcBvb+TLIaIJdRyz0Np5dkL3sd4c79m9yOuIJl JzdyNJP+49LWkcDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BAF0A1391C; Fri, 27 Oct 2023 16:23:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id LcAyLQ/kO2X7NgAAMHmgww (envelope-from ); Fri, 27 Oct 2023 16:23:43 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 39942A06E3; Fri, 27 Oct 2023 18:23:43 +0200 (CEST) From: Jan Kara To: Cc: Jan Kara Subject: [PATCH 1/3] quota: Replace BUG_ON in dqput() Date: Fri, 27 Oct 2023 18:23:37 +0200 Message-Id: <20231027162343.28366-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231027161930.27648-1-jack@suse.cz> References: <20231027161930.27648-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=782; i=jack@suse.cz; h=from:subject; bh=6t9jOcFqT4xANRA3GvWM2Ww+FIx8dlrkh721hWqR8fA=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBlO+QJbxOQBhE3yPjHm1iuzlupr76vMqh8M0QNrE8Z Ecf/pZaJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZTvkCQAKCRCcnaoHP2RA2a31CA Daeetv07UkloIj4U0fZpZyyn8HxgBrxub6VvAB2VaUa0SZRYVqFP5WYv/cgHhX6okUJAlVbuen//g3 jgkbgKteTqHGwDG8qy+TBHtkzXpSmC2Kcd76RvRlpmENSy/M+FRvWJbExXcnimpmlqLukzLwIW0x10 50XLf4lCwXR6UP0sGLiCSDr88jDkXq1/ZoEXMW7mNEZVfAY82vszJzH1EseMslzsx6c3FxSEDxCS0y ZIbgCBR0lQOYsOWS/o9Jy3VhCKicPCLRVxVUcHlpvRxb5/D6Bg24jewYq5hc3gz+xFVLbWv98qcbuF fOgD4NXz7J9rM/CUGsCSiNkvwDPJtv X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -2.10 X-Spamd-Result: default: False [-2.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[99.99%] The BUG_ON in dqput() will likely take the whole machine down when it hits. Replace it with WARN_ON_ONCE() instead and stop hiding that behind CONFIG_QUOTA_DEBUG. Signed-off-by: Jan Kara --- fs/quota/dquot.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 31e897ad5e6a..c0d778363435 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -881,10 +881,7 @@ void dqput(struct dquot *dquot) } /* Need to release dquot? */ -#ifdef CONFIG_QUOTA_DEBUG - /* sanity check */ - BUG_ON(!list_empty(&dquot->dq_free)); -#endif + WARN_ON_ONCE(!list_empty(&dquot->dq_free)); put_releasing_dquots(dquot); atomic_dec(&dquot->dq_count); spin_unlock(&dq_list_lock); From patchwork Fri Oct 27 16:23:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13438629 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8FCA38BCC for ; Fri, 27 Oct 2023 16:23:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="xsX0I4kt"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="Hy6RhRO9" Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E3CD116 for ; Fri, 27 Oct 2023 09:23:45 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DB1B31FEF8; Fri, 27 Oct 2023 16:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1698423823; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R5BooIwSB54tvmZnZk+gxHiTFBUv20KWiSFg51DMzH8=; b=xsX0I4ktJvdJTVwO/pE7Tfkln8CArRKd7FegHG1VmbT4Rx9YH7HZA2cZN2rSXsZ+i3l/Ll PSt8d2o2wO1qIH6zWG+/uKLQt/a6DAG7LmUd5e9AHhyLmL2nVLhHMAZvDrX4qX6ngawNay ad0/folYAMLKz6F1bIne36VQSdWBHkE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1698423823; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R5BooIwSB54tvmZnZk+gxHiTFBUv20KWiSFg51DMzH8=; b=Hy6RhRO9e9Xcb7IzRFrhmYmqfeJvL+pTXUAl/Is5Kf2vzaaZqtwHI1lTg76Z0Qpp0wEB2O bjIZBIWHNwVjm7Bg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C362413A66; Fri, 27 Oct 2023 16:23:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RtJSLw/kO2UBNwAAMHmgww (envelope-from ); Fri, 27 Oct 2023 16:23:43 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 3F3F5A06E5; Fri, 27 Oct 2023 18:23:43 +0200 (CEST) From: Jan Kara To: Cc: Jan Kara Subject: [PATCH 2/3] quota: Remove BUG_ON in dquot_load_quota_sb() Date: Fri, 27 Oct 2023 18:23:38 +0200 Message-Id: <20231027162343.28366-2-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231027161930.27648-1-jack@suse.cz> References: <20231027161930.27648-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=810; i=jack@suse.cz; h=from:subject; bh=9UNCT2Bf4mz35j9wEx5538/pRGOgLONERvcgKTf/pqk=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBlO+QKa09LlphDRxMu6NavR5LUAtYpM8U3qDOs5x+5 HbGa/2yJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZTvkCgAKCRCcnaoHP2RA2cLUCA ChadbASdEsgj7qWOc0nHNhwLqPKSTCvbZ6/C6eoOSYBt8r4vlwA5mIPUWZrx2DREivcESAtcbX/bnp Dqu1540krbW0xRhadpQxe3CF09XD6AacIc39zfqFA1gdDZm64BGVxUVB8Tm3rGpVThyV0g/6g6NzGt oEuUm70vr2c1OQECJXfh+jHdJcq6kbHL6SFCibSWOyrtaBr7fM657N46ixK9uQi5GpQZx9pPe0b9Pn /vz6a1Xmd0psWMvbymJfC+lZVZlWxjxv40B0+3WvEKggK7Yx41cIf+Vj0+o0t8S7YTZueLOb/VSGrR 1+YvjYc9u/2+1wmv08kt6EPAjkM2qm X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C The case when someone passes DQUOT_SUSPENDED flag to dquot_load_quota_sb() is easy to handle. So just WARN_ON_ONCE and bail with error if that happens instead of calling BUG_ON which is likely to lockup the machine. Signed-off-by: Jan Kara --- fs/quota/dquot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index c0d778363435..f0bb8367641f 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2377,7 +2377,8 @@ int dquot_load_quota_sb(struct super_block *sb, int type, int format_id, lockdep_assert_held_write(&sb->s_umount); /* Just unsuspend quotas? */ - BUG_ON(flags & DQUOT_SUSPENDED); + if (WARN_ON_ONCE(flags & DQUOT_SUSPENDED)) + return -EINVAL; if (!fmt) return -ESRCH; From patchwork Fri Oct 27 16:23:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13438630 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C2A838BD9 for ; Fri, 27 Oct 2023 16:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="xuBMh8NN"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="4mcm1SZK" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DB23129 for ; Fri, 27 Oct 2023 09:23:45 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D43E521CA3; Fri, 27 Oct 2023 16:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1698423823; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gx/Nf9CxSU9qwDuTJtA10LvYYXvqXuRU4zJwoIDPysA=; b=xuBMh8NNcH6ly+LiZl+jpZR+v2w+JaReziJFzJ1ict5VnowVnkaRfWXtiLsRtq2T0uHhkc UF5572fufrqtsFL0VkPthzz7lXfwQp2JEMiEYQ5OJ0iFiK8S2scnTHoqGKbnC8nrY7ks0N 0MA3cTNHM/HHnjHdRnTsjGtTNzypU9w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1698423823; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gx/Nf9CxSU9qwDuTJtA10LvYYXvqXuRU4zJwoIDPysA=; b=4mcm1SZKQag5+BIfXcXqOa2woTifRlt3ZLR4EREcPy0WbmV1nBJP4Z53piaR5dokWuvK4X VYW+2FvPXYnJd2Dg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BEB2E13A0E; Fri, 27 Oct 2023 16:23:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id F2CELg/kO2X/NgAAMHmgww (envelope-from ); Fri, 27 Oct 2023 16:23:43 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 45894A0759; Fri, 27 Oct 2023 18:23:43 +0200 (CEST) From: Jan Kara To: Cc: Jan Kara Subject: [PATCH 3/3] quota: Remove BUG_ON from dqget() Date: Fri, 27 Oct 2023 18:23:39 +0200 Message-Id: <20231027162343.28366-3-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231027161930.27648-1-jack@suse.cz> References: <20231027161930.27648-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=994; i=jack@suse.cz; h=from:subject; bh=DJbutlkZS0y3a0YtTt0KLHQV01Gte9tgl6SyrWn4RAM=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBlO+QLBLdsrJTpqZ10nfXDwLMc29ccR8Urdf9LqjFq yu2rkciJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZTvkCwAKCRCcnaoHP2RA2VYwB/ 0Tod7UhnNla/eGwWbYH3MolwXrIyKI2xX6o4NsyxcMMElhAUY9vH+QSDKIrYnq9WRaSN0kxdsjgvL2 bwZiWnkRGqsSsEc1kGAHgZt6W0bw4C8mNIBsXvfEIDQPfdmSMyfOEPy1VkvGGZ5V9wDmbcOFkNtw/Z gkU8PtqkY4aVjd6yaQgPQjX/k6D2yjdMQ/tXKgaoBz1lc71McnqiQ1I/9fWvjsTWLoa0oTXw188/1A qH6rhCt3xDmn59xkC5EIRGIZkFCOe4WLjy1pqZNnNC4T8u8eDCKMyg2MncxYWOJq9popt0UvsImPIR uTp8RsUmuKyC7wF8rDbECytIETlC3w X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -6.10 X-Spamd-Result: default: False [-6.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[99.99%] dqget() checks whether dquot->dq_sb is set when returning it using BUG_ON. Firstly this doesn't work as an invalidation check for quite some time (we release dquot with dq_sb set these days), secondly using BUG_ON is quite harsh. Use WARN_ON_ONCE and check whether dquot is still hashed instead. Signed-off-by: Jan Kara --- fs/quota/dquot.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index f0bb8367641f..7cd83443e3eb 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -990,9 +990,8 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid) * smp_mb__before_atomic() in dquot_acquire(). */ smp_rmb(); -#ifdef CONFIG_QUOTA_DEBUG - BUG_ON(!dquot->dq_sb); /* Has somebody invalidated entry under us? */ -#endif + /* Has somebody invalidated entry under us? */ + WARN_ON_ONCE(hlist_unhashed(&dquot->dq_hash)); out: if (empty) do_destroy_dquot(empty);