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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DF71C7EE25 for ; Wed, 7 Jun 2023 13:14:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g3qm10BFMOoxWlTfzY02rDFkH1MgJHM90hSPqL0EKSU=; b=RpzrnsDXcUyS3QpiLeONM8pNwW P/KOZFUkLHLEUim5SNQiyoV+GbxrJVQ2rH2XG3HykdHdKXIQdyeaxi3t8c97om1NfmuesYmkLBPMb 0aPb3P6QN603CiOXJjwqRCNw6OPhmAY1mQbubdOPOySA55C9LSVQPnWiptVM5/JpCxUrcuFnuR6UR SAntVc07z/Xu6+2b+LBC1KOVbd3dRKsBmR0GqAltpP2FuKWPacrVcPdkw6D2jHJk0cyPIfmytr+ZM nJvFwKXZoCKi0u/JBgBCTDCngq5VMtMd2gXC+23uT3k6Bf4vispE5Wg/BBH2ZdvvrVnlHog3Zsl22 Jz8Smk/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6szo-0063ro-1s; Wed, 07 Jun 2023 13:14:40 +0000 Received: from smtp-out1.suse.de ([2001:67c:2178:6::1c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6szk-0063qZ-34; Wed, 07 Jun 2023 13:14:38 +0000 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 A641A219FE; Wed, 7 Jun 2023 13:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686143675; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g3qm10BFMOoxWlTfzY02rDFkH1MgJHM90hSPqL0EKSU=; b=h0v2DqBB9ySJiLnmn6KXn42VRK0Z/nPXxfHyl6P9vx/g51yoRFC9AAW5wAXqURmVlJIrCN 2D+/sGF0Dbl/023m3VKR+jyJmZpI81N2dxOsOVo1Iyv6eQHVy55am5AqqgqG5JbeU+LsvI y9I3aAtB7v6O/td5ghW63FzKVmGA63w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686143675; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g3qm10BFMOoxWlTfzY02rDFkH1MgJHM90hSPqL0EKSU=; b=nE+HbFK6uzo+zBGVf8a/fbVecve2gD4PPeEmbpshgySHxZDiiPHczbZcJawWlwnNHAICqS Q/nUJxr0GbT6aJBg== 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 7308A1346D; Wed, 7 Jun 2023 13:14:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uiivG7uCgGS9YAAAMHmgww (envelope-from ); Wed, 07 Jun 2023 13:14:35 +0000 Message-ID: <04517ec2-bf6c-0783-9494-fb12a89d07a0@suse.de> Date: Wed, 7 Jun 2023 15:14:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 30/31] block: store the holder in file->private_data Content-Language: en-US To: Christoph Hellwig , Jens Axboe Cc: Richard Weinberger , Josef Bacik , "Md. Haris Iqbal" , Jack Wang , Phillip Potter , Coly Li , Miquel Raynal , Vignesh Raghavendra , "Martin K. Petersen" , Chris Mason , David Sterba , Alexander Viro , Christian Brauner , "Rafael J. Wysocki" , Pavel Machek , dm-devel@redhat.com, linux-block@vger.kernel.org, linux-um@lists.infradead.org, linux-scsi@vger.kernel.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-pm@vger.kernel.org References: <20230606073950.225178-1-hch@lst.de> <20230606073950.225178-31-hch@lst.de> From: Hannes Reinecke In-Reply-To: <20230606073950.225178-31-hch@lst.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_061437_133798_F8257322 X-CRM114-Status: GOOD ( 23.54 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org On 6/6/23 09:39, Christoph Hellwig wrote: > Store the file struct used as the holder in file->private_data as an > indicator that this file descriptor was opened exclusively to remove > the last use of FMODE_EXCL. > > Signed-off-by: Christoph Hellwig > --- > block/fops.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/block/fops.c b/block/fops.c > index c40b9f978e3bc7..915e0ef7560993 100644 > --- a/block/fops.c > +++ b/block/fops.c > @@ -478,7 +478,7 @@ blk_mode_t file_to_blk_mode(struct file *file) > mode |= BLK_OPEN_READ; > if (file->f_mode & FMODE_WRITE) > mode |= BLK_OPEN_WRITE; > - if (file->f_mode & FMODE_EXCL) > + if (file->private_data) > mode |= BLK_OPEN_EXCL; > if ((file->f_flags & O_ACCMODE) == 3) > mode |= BLK_OPEN_WRITE_IOCTL; > @@ -501,12 +501,15 @@ static int blkdev_open(struct inode *inode, struct file *filp) > filp->f_flags |= O_LARGEFILE; > filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; > > + /* > + * Use the file private data to store the holder, file_to_blk_mode > + * relies on this. > + */ Can you update the comment to reflect that we're only use the ->private_data field for exclusive open? I know it's indicated by the condition, but we really should be clarify this usage. > if (filp->f_flags & O_EXCL) > - filp->f_mode |= FMODE_EXCL; > + filp->private_data = filp; > > bdev = blkdev_get_by_dev(inode->i_rdev, file_to_blk_mode(filp), > - (filp->f_mode & FMODE_EXCL) ? filp : NULL, > - NULL); > + filp->private_data, NULL); > if (IS_ERR(bdev)) > return PTR_ERR(bdev); > > @@ -517,8 +520,7 @@ static int blkdev_open(struct inode *inode, struct file *filp) > > static int blkdev_release(struct inode *inode, struct file *filp) > { > - blkdev_put(I_BDEV(filp->f_mapping->host), > - (filp->f_mode & FMODE_EXCL) ? filp : NULL); > + blkdev_put(I_BDEV(filp->f_mapping->host), filp->private_data); > return 0; > } > Other than that: Reviewed-by: Hannes Reinecke Cheers, Hannes