Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2210810ybv; Mon, 24 Feb 2020 01:09:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwLK7jzo8Vb5LM+e2TVsI/BMkHmpSnGjLIWv++RIU/w1yilLQlCTCaX+gjJVYjuSinhekK7 X-Received: by 2002:aca:1a06:: with SMTP id a6mr11243800oia.148.1582535347736; Mon, 24 Feb 2020 01:09:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582535347; cv=none; d=google.com; s=arc-20160816; b=WU24ysTDWajuw/h/ih98WZVvjfVuWbb2+pPvCGnVNBqV+MjRdh3TGjS6eeSmUO/NUX 6ooHarvOlCqvk8lk07YMhcQE9yF0TaY33cF8XsYJMla+NmYO5iZnf8bEfGG35FmVHjle I7LuMqUON4UYcTu1ixwcScperweml9oQUr/yXhVfxqKPBUExZEUb+aetTMHdGwZERdTM mpvITocri2Aza8Yc35m6zzJbrlo2sTy+uZPcSkXaEyrA1vE827+Ry9SGWjgiY/gN5jUt DDO+1Wdd3czsHY3WDSg7tDtPDzsDsmPu2ADgmtDB+PHWk7Eej35zTQmmSajJd2jduAo4 3i+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=5bvqKRZINFl77FWiK0wDnvCL/wIfPyL2cQyIr/xItMw=; b=jMqLEQShmvwtCGxLyG8jhwYDessPnScO66lj5MbJqbANET3hN5HLG3NQvA/S/1JAgC fjhmvvIZVIL7NNoTpjl2hlXyEc/lqLtT9tJw3MhXb7og+lt9AVHSlMc2zUnUJMGPdvXN iEGb4DGFjeFzdLmhM64b7/C5Qh2gMjo6gmG5Sl50hDU5aehbC4qudpPbUUd98VLWp3Dd 65JH3eToVgujSlVPgC/PrNS5qjotWMiuvSUr6+CrSVN5vVhE5zDMrkjq/W4qYAmLGvGd kNOBjwsAXjXgzIb7ziyQqmo8JzvVrEJMoOEiIT4XpwxgrsdpCWEwtONPbHkpcoPwQHSu FcKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m16si6583372otj.7.2020.02.24.01.08.51; Mon, 24 Feb 2020 01:09:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbgBXJIr (ORCPT + 99 others); Mon, 24 Feb 2020 04:08:47 -0500 Received: from mx2.suse.de ([195.135.220.15]:41408 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbgBXJIr (ORCPT ); Mon, 24 Feb 2020 04:08:47 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 36F58AC92; Mon, 24 Feb 2020 09:08:45 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id AA41F1E0E33; Mon, 24 Feb 2020 10:08:46 +0100 (CET) Date: Mon, 24 Feb 2020 10:08:46 +0100 From: Jan Kara To: "J. R. Okajima" Cc: jack@suse.com, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: ext2, possible circular locking dependency detected Message-ID: <20200224090846.GB27857@quack2.suse.cz> References: <4946.1582339996@jrobl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4946.1582339996@jrobl> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hello! On Sat 22-02-20 11:53:16, J. R. Okajima wrote: > Hello ext2 maintainers, > > During my local fs stress test, I've encounter this. > Is it false positive? > Otherwise, I've made a small patch to stop reclaming recursively into FS > from ext2_xattr_set(). Please consider taking this. > > Once I've considered about whether it should be done in VFS layer or > not. I mean, every i_op->brabra() calls in VFS should be surrounded by > memalloc_nofs_{save,restore}(), by a macro or something. But I am > afraid it may introduce unnecesary overheads, especially when FS code > doesn't allocate memory. So it is better to do it in real FS > operations. Thanks for debugging this and for the patch. One comment below: ... > @@ -532,7 +534,9 @@ ext2_xattr_set(struct inode *inode, int name_index, const char *name, > > unlock_buffer(bh); > ea_bdebug(bh, "cloning"); > + nofs_flag = memalloc_nofs_save(); > header = kmemdup(HDR(bh), bh->b_size, GFP_KERNEL); > + memalloc_nofs_restore(nofs_flag); > error = -ENOMEM; > if (header == NULL) > goto cleanup; > @@ -545,7 +549,9 @@ ext2_xattr_set(struct inode *inode, int name_index, const char *name, > } > } else { > /* Allocate a buffer where we construct the new block. */ > + nofs_flag = memalloc_nofs_save(); > header = kzalloc(sb->s_blocksize, GFP_KERNEL); > + memalloc_nofs_restore(nofs_flag); > error = -ENOMEM; > if (header == NULL) > goto cleanup; This is not the right way how memalloc_nofs_save() should be used (you could just use GFP_NOFS instead of GFP_KERNEL instead of wrapping the allocation inside memalloc_nofs_save/restore()). The memalloc_nofs_save/restore() API is created so that you can change the allocation context at the place which mandates the new context - i.e., in this case when acquiring / dropping xattr_sem. That way you don't have to propagate the context information down to function calls and the code is also future-proof - if you add new allocation, they will use correct allocation context. Honza -- Jan Kara SUSE Labs, CR