Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7658025rdb; Thu, 4 Jan 2024 03:50:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4g4DZPC4p76i/SPe2MysgIEGyBsW7G6zR6ohD2OpNElDP9Jz0SLwgocYQDWRZSFJj5mQL X-Received: by 2002:a17:903:268a:b0:1d3:65b0:838a with SMTP id jf10-20020a170903268a00b001d365b0838amr348562plb.131.1704369028182; Thu, 04 Jan 2024 03:50:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704369028; cv=none; d=google.com; s=arc-20160816; b=c3Yt3ZRmTkOjWmuX22RDLyj9Mb8ILRwP84sDxyfQjuqbLJNe6hT2brX+BBDziwJtZE F++7Nk8F0b8RPT4sspy2fhH893zleAlvIK0cEJArbJ2fLw7bgrOinVXd1KOg7GVs/MS+ KwTDQiuwagH44c/FwFyN4LzRaRE07pAzv9J+Uz7on+IibtiBhGi6q+BPWEpLpPRt7qxU qKqx2VUIdIbmEZ5s0vWVjN+/7zk4LFzhn1uUb2pOm5Tisci8Sm41JfJlj1+3fOkH7ins 5Twuy7Xin3UhoXVPwFTTCqbFsgULhl8T2VtR0A4y+5VZY9U2Bgxa+ANjqGAnHe66V21k Aieg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=XeXpcnQhc7k5wPj1KeDdzxd8IqzZglYqdEMHG+1v698=; fh=hdmhxUMxVhj5iF7Np6mqN5LS9kFw5JhFoBDd+ZgIdWk=; b=f6w2ceqEyLCY5P4GMiPINOpb30kE4NiJpmjzjYTJYkEqnw+XiTauqqm7F21hmOSSnx zit6575ptmD6L9X/U7Ee5wPIsA5VdnDbJ7RlQOnGs0wjB5QRIAu/tGH/C2FTVvYCx8cp JqoFVVQ5S3T/Jp2oy7CTarf4NyqvqoTDnmUhTDotjRGKJydO6Cf/kWtrhu0T7CyDEnLz cNa6zrdsGhyCk0Yz8hMumV/47wm6NAMm/mrI2rNUckRhI4zpF2XzQDinSBxiw+NUoDdH 6lbiAK0RhjDZngzA+esHP7oIoOZxuldsXKs+NbqqFAPNp8Kt7Wffw4XrNjFwQ30yR2Ju tt3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=LPy9kLPa; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=LPy9kLPa; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=RfDu2tLA; spf=pass (google.com: domain of linux-ext4+bounces-681-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-681-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id r7-20020a1709028bc700b001d3c7b8f9d6si11710267plo.427.2024.01.04.03.50.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 03:50:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-681-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=LPy9kLPa; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=LPy9kLPa; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=RfDu2tLA; spf=pass (google.com: domain of linux-ext4+bounces-681-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-681-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B277D2862D8 for ; Thu, 4 Jan 2024 11:50:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D6AC21373; Thu, 4 Jan 2024 11:50:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="LPy9kLPa"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="RfDu2tLA"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="LPy9kLPa"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="RfDu2tLA" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4899921346; Thu, 4 Jan 2024 11:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 160C121EF5; Thu, 4 Jan 2024 11:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1704369003; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XeXpcnQhc7k5wPj1KeDdzxd8IqzZglYqdEMHG+1v698=; b=LPy9kLPa52w1LTjGtPYNG0ddRTaUsK2l/chyWjlrzN9YlPHEcnuQYee5oABFJTvAftkB9q FjI0zQ5uCaFFznkd94synnqXs7uXb8cRAAI7EO6ytDym9jLmWBPX0BO4sb7N9wbnW2+LFu 0aOzGcbzAFq+5BQ61moeUz08HE5ZlKs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1704369003; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XeXpcnQhc7k5wPj1KeDdzxd8IqzZglYqdEMHG+1v698=; b=RfDu2tLAXy86TXl7DP8sQxwxqulz8lo88WAB157ByWrDk4aXKD88/w5gosTD/z+q/d5Hzm g3+FRHbpwvRn6XCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1704369003; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XeXpcnQhc7k5wPj1KeDdzxd8IqzZglYqdEMHG+1v698=; b=LPy9kLPa52w1LTjGtPYNG0ddRTaUsK2l/chyWjlrzN9YlPHEcnuQYee5oABFJTvAftkB9q FjI0zQ5uCaFFznkd94synnqXs7uXb8cRAAI7EO6ytDym9jLmWBPX0BO4sb7N9wbnW2+LFu 0aOzGcbzAFq+5BQ61moeUz08HE5ZlKs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1704369003; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XeXpcnQhc7k5wPj1KeDdzxd8IqzZglYqdEMHG+1v698=; b=RfDu2tLAXy86TXl7DP8sQxwxqulz8lo88WAB157ByWrDk4aXKD88/w5gosTD/z+q/d5Hzm g3+FRHbpwvRn6XCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 05B81137E8; Thu, 4 Jan 2024 11:50:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id N5lgAWublmUQDAAAD6G6ig (envelope-from ); Thu, 04 Jan 2024 11:50:03 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id A9CF6A07EF; Thu, 4 Jan 2024 12:49:58 +0100 (CET) Date: Thu, 4 Jan 2024 12:49:58 +0100 From: Jan Kara To: Matthew Wilcox Cc: Yu Kuai , axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: Re: [PATCH RFC v3 for-6.8/block 09/17] btrfs: use bdev apis Message-ID: <20240104114958.f3cit5q7syp3tn3a@quack3> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> <20231221085712.1766333-10-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: 1.65 X-Spamd-Bar: + X-Spam-Flag: NO X-Spamd-Result: default: False [1.65 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; BAYES_HAM(-0.04)[57.99%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_RATELIMIT(0.00)[to_ip_from(RLhr85cyeg3mfw7iggddtjdkgs)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWELVE(0.00)[48]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.cz:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; FREEMAIL_CC(0.00)[huaweicloud.com,kernel.dk,citrix.com,suse.de,gmail.com,lazybastard.org,bootlin.com,nod.at,ti.com,linux.ibm.com,oracle.com,fb.com,toxicpanda.com,suse.com,zeniv.linux.org.uk,kernel.org,fluxnic.net,mit.edu,dilger.ca,linux-foundation.org,samsung.com,vger.kernel.org,lists.xenproject.org,lists.infradead.org,lists.ozlabs.org,huawei.com]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from] Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=LPy9kLPa; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=RfDu2tLA X-Spam-Level: * X-Rspamd-Queue-Id: 160C121EF5 On Sat 23-12-23 17:31:55, Matthew Wilcox wrote: > On Thu, Dec 21, 2023 at 04:57:04PM +0800, Yu Kuai wrote: > > @@ -3674,16 +3670,17 @@ struct btrfs_super_block *btrfs_read_dev_one_super(struct block_device *bdev, > > * Drop the page of the primary superblock, so later read will > > * always read from the device. > > */ > > - invalidate_inode_pages2_range(mapping, > > - bytenr >> PAGE_SHIFT, > > + invalidate_bdev_range(bdev, bytenr >> PAGE_SHIFT, > > (bytenr + BTRFS_SUPER_INFO_SIZE) >> PAGE_SHIFT); > > } > > > > - page = read_cache_page_gfp(mapping, bytenr >> PAGE_SHIFT, GFP_NOFS); > > - if (IS_ERR(page)) > > - return ERR_CAST(page); > > + nofs_flag = memalloc_nofs_save(); > > + folio = bdev_read_folio(bdev, bytenr); > > + memalloc_nofs_restore(nofs_flag); > > This is the wrong way to use memalloc_nofs_save/restore. They should be > used at the point that the filesystem takes/releases whatever lock is > also used during reclaim. I don't know btrfs well enough to suggest > what lock is missing these annotations. In principle I agree with you but in this particular case I agree the ask is just too big. I suspect it is one of btrfs btree locks or maybe chunk_mutex but I doubt even btrfs developers know and maybe it is just a cargo cult. And it is not like this would be the first occurence of this anti-pattern in btrfs - see e.g. device_list_add(), add_missing_dev(), btrfs_destroy_delalloc_inodes() (here the wrapping around invalidate_inode_pages2() looks really weird), and many others... Honza -- Jan Kara SUSE Labs, CR