From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hannes Reinecke Subject: Re: [PATCH 30/31] block: store the holder in file->private_data Date: Wed, 7 Jun 2023 15:14:35 +0200 Message-ID: <04517ec2-bf6c-0783-9494-fb12a89d07a0@suse.de> References: <20230606073950.225178-1-hch@lst.de> <20230606073950.225178-31-hch@lst.de> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: 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== Content-Language: en-US In-Reply-To: <20230606073950.225178-31-hch-jcswGhMUV9g@public.gmane.org> List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-um-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.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