From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75FC8C433E7 for ; Thu, 15 Oct 2020 09:51:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B5CF2224A for ; Thu, 15 Oct 2020 09:51:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389014AbgJOJvw (ORCPT ); Thu, 15 Oct 2020 05:51:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:39118 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388789AbgJOJvw (ORCPT ); Thu, 15 Oct 2020 05:51:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id AA9A7B138; Thu, 15 Oct 2020 09:51:51 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 698181E1338; Thu, 15 Oct 2020 11:51:51 +0200 (CEST) Date: Thu, 15 Oct 2020 11:51:51 +0200 From: Jan Kara To: Andreas Dilger Cc: Jan Kara , Ted Tso , linux-ext4@vger.kernel.org, Ritesh Harjani Subject: Re: [PATCH] ext4: Detect already used quota file early Message-ID: <20201015095151.GD7037@quack2.suse.cz> References: <20201013132221.22725-1-jack@suse.cz> <43A89FE1-E2B2-4751-B79B-C99C3F15B1A8@dilger.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43A89FE1-E2B2-4751-B79B-C99C3F15B1A8@dilger.ca> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu 15-10-20 01:33:24, Andreas Dilger wrote: > On Oct 13, 2020, at 7:22 AM, Jan Kara wrote: > > > > When we try to use file already used as a quota file again (for the same > > or different quota type), strange things can happen. At the very least > > lockdep annotations may be wrong but also inode flags may be wrongly set > > / reset. When the file is used for two quota types at once we can even > > corrupt the file and likely crash the kernel. Catch all these cases by > > checking whether passed file is already used as quota file and bail > > early in that case. > > > > This fixes occasional generic/219 failure due to lockdep complaint. > > > > Reported-by: Ritesh Harjani > > Signed-off-by: Jan Kara > > Patch looks OK, but a minor question/suggestion below... > > Reviewed-by: Andreas Dilger > > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > > index ea425b49b345..49b2e6be35c4 100644 > > --- a/fs/ext4/super.c > > +++ b/fs/ext4/super.c > > @@ -6042,6 +6042,11 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, > > /* Quotafile not on the same filesystem? */ > > if (path->dentry->d_sb != sb) > > return -EXDEV; > > + > > + /* Quota already enabled for this file? */ > > + if (path->dentry->d_inode->i_flags & S_NOQUOTA) > > + return -EBUSY; > > Any reason not to use IS_NOQUOTA(path->dentry->d_inode) here? I was trying > to see where S_NOQUOTA is set, and it seems that all of the quota code is > using IS_NOQUOTA(). OK, right. I'll change that. Thanks for review. Honza -- Jan Kara SUSE Labs, CR