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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C42A8C3DA66 for ; Fri, 25 Aug 2023 13:48:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2912228007F; Fri, 25 Aug 2023 09:48:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2417D8E0015; Fri, 25 Aug 2023 09:48:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E2DC28007F; Fri, 25 Aug 2023 09:48:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F16A98E0015 for ; Fri, 25 Aug 2023 09:48:03 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C074FC06A3 for ; Fri, 25 Aug 2023 13:48:03 +0000 (UTC) X-FDA: 81162755646.27.208867F Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf26.hostedemail.com (Postfix) with ESMTP id 90F3C14001E for ; Fri, 25 Aug 2023 13:48:00 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=uohLnKnq; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="avw/hNX+"; dmarc=none; spf=pass (imf26.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971281; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BpzfsfMiRxmg30OdFnKzv1mOgTevyt5wkPNcyneGwG0=; b=zdtSEa9UtQeycufotulR2hky7ZtfiqxcOWSVnUIgHlsxRLi50Ex9ywHeWaKVNdnIe4+CeB dr+mg3WsEIGFGm8k5k+9sXDWETl+lXNkGMZBrVNthLDkdDig2cYBJl8f59BEIeZtjbsEkM QVaIB6Z+tt/qk0aL1VT8Xopj4rs+yfw= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=uohLnKnq; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="avw/hNX+"; dmarc=none; spf=pass (imf26.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971281; a=rsa-sha256; cv=none; b=oddxGmFYk4xAd+MhZx8XE0ov4PYel1fbydSBtXuGi6zAlBqMe0ZpyC96ri7gGmVApNs5PY XZnyzPoFAaYVsXF7JmDsemRIE4DbNAErG4Ay/oqYRIbuKOL7COktmy/YOquYs55TQFxvuC ztutqkQEK+2F7/ysSqCjIEWcxx+zuaI= 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 49AEC21F79; Fri, 25 Aug 2023 13:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1692971277; 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=BpzfsfMiRxmg30OdFnKzv1mOgTevyt5wkPNcyneGwG0=; b=uohLnKnqtpENx2vCia+CF25VunAvqKNxW8Gl/JZPjm2522sG0QzHP89CKm9gvg5uhIQmJN WBEcUX07tygEsfRFeW0MDCmmX2lneinhEWFdq+jYTgqP+tDCYKowqEsMW88igvW28lrojs hfcd/30g2Ie/qrM4mt7e3dhBm3c9V28= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1692971277; 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=BpzfsfMiRxmg30OdFnKzv1mOgTevyt5wkPNcyneGwG0=; b=avw/hNX+TPhBa6q/Pyjq6dsHiVTX81moNODEW9+kRWtkr4cKF/cxPXXUPquXV79uoK0IL4 nSbq/d/haJGtPRAQ== 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 28033138F9; Fri, 25 Aug 2023 13:47:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UJRbCQ2x6GQZAwAAMHmgww (envelope-from ); Fri, 25 Aug 2023 13:47:57 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id A432FA0774; Fri, 25 Aug 2023 15:47:56 +0200 (CEST) Date: Fri, 25 Aug 2023 15:47:56 +0200 From: Jan Kara To: Al Viro Cc: Jan Kara , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig , Alasdair Kergon , Andrew Morton , Anna Schumaker , Chao Yu , Christian Borntraeger , "Darrick J. Wong" , Dave Kleikamp , David Sterba , dm-devel@redhat.com, drbd-dev@lists.linbit.com, Gao Xiang , Jack Wang , Jaegeuk Kim , jfs-discussion@lists.sourceforge.net, Joern Engel , Joseph Qi , Kent Overstreet , linux-bcache@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mm@kvack.org, linux-mtd@lists.infradead.org, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-nvme@lists.infradead.org, linux-pm@vger.kernel.org, linux-raid@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-xfs@vger.kernel.org, "Md. Haris Iqbal" , Mike Snitzer , Minchan Kim , ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org, Sergey Senozhatsky , Song Liu , Sven Schnelle , target-devel@vger.kernel.org, Ted Tso , Trond Myklebust , xen-devel@lists.xenproject.org, Jens Axboe , Christian Brauner Subject: Re: [PATCH v2 0/29] block: Make blkdev_get_by_*() return handle Message-ID: <20230825134756.o3wpq6bogndukn53@quack3> References: <20230810171429.31759-1-jack@suse.cz> <20230825015843.GB95084@ZenIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230825015843.GB95084@ZenIV> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 90F3C14001E X-Stat-Signature: yxjqbgzd31upa7tubbdm7tt5raqgp6gd X-HE-Tag: 1692971280-187359 X-HE-Meta: U2FsdGVkX19AViZOJTUP/uhDdx+rZoNQAIb+1zTdxxxGnYNp0D33JmR1US3j5vXFbP6NmhGsLAVUkbtYim8cy7aGfS6Uu9oWi2KmzAhCH2F0Kxs03+BE+z5R3E4xOySpZd6w4lBYhK8kWsIP4tL362oU0Kbv8e1fMu//EgCRyQvSkm3V6KY8BmTwDE9ETFwT19FPrX+73yfiDAZsT6ja9vpEt6hFNMqLtdFdJqMplicRtrahsuSsbkMYm4LobNbeH3kRzBNG7VnUlB0BGbbwfXZgUTNWXKtCJU7ih85Mbk+jbPk9Ljff8Eocv7yVdBDVvYv6C32h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ze6Gz6x6KELsOXmy4GRxKngW6Kg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri 25-08-23 02:58:43, Al Viro wrote: > On Fri, Aug 11, 2023 at 01:04:31PM +0200, Jan Kara wrote: > > Hello, > > > > this is a v2 of the patch series which implements the idea of blkdev_get_by_*() > > calls returning bdev_handle which is then passed to blkdev_put() [1]. This > > makes the get and put calls for bdevs more obviously matching and allows us to > > propagate context from get to put without having to modify all the users > > (again!). In particular I need to propagate used open flags to blkdev_put() to > > be able count writeable opens and add support for blocking writes to mounted > > block devices. I'll send that series separately. > > > > The series is based on Christian's vfs tree as of yesterday as there is quite > > some overlap. Patches have passed some reasonable testing - I've tested block > > changes, md, dm, bcache, xfs, btrfs, ext4, swap. This obviously doesn't cover > > everything so I'd like to ask respective maintainers to review / test their > > changes. Thanks! I've pushed out the full branch to: > > > > git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git bdev_handle > > > > to ease review / testing. > > Hmm... Completely Insane Idea(tm): how about turning that thing inside out and > having your bdev_open_by... return an actual opened struct file? > > After all, we do that for sockets and pipes just fine and that's a whole lot > hotter area. > > Suppose we leave blkdev_open()/blkdev_release() as-is. No need to mess with > what we have for normal opened files for block devices. And have block_open_by_dev() > that would find bdev, etc., same yours does and shove it into anon file. > > Paired with plain fput() - no need to bother with new primitives for closing. > With a helper returning I_BDEV(bdev_file_inode(file)) to get from those to bdev. > > NOTE: I'm not suggesting replacing ->s_bdev with struct file * if we do that - > we want that value cached, obviously. Just store both... > > Not saying it's a good idea, but... might be interesting to look into. > Comments? I can see the appeal of not having to introduce the new bdev_handle type and just using struct file which unifies in-kernel and userspace block device opens. But I can see downsides too - the last fput() happening from task work makes me a bit nervous whether it will not break something somewhere with exclusive bdev opens. Getting from struct file to bdev is somewhat harder but I guess a helper like F_BDEV() would solve that just fine. So besides my last fput() worry about I think this could work and would be probably a bit nicer than what I have. But before going and redoing the whole series let me gather some more feedback so that we don't go back and forth. Christoph, Christian, Jens, any opinion? Honza -- Jan Kara SUSE Labs, CR