Message ID | 20200917165720.3285256-10-hch@lst.de |
---|---|
State | Not Applicable |
Delegated to: | David Miller |
Headers | show |
Series | [01/14] block: move the NEED_PART_SCAN flag to struct gendisk | expand |
On 2020/9/18 00:57, Christoph Hellwig wrote: > Use blkdev_get_by_dev instead of igrab (aka open coded bdgrab) + > blkdev_get. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> > --- > fs/ocfs2/cluster/heartbeat.c | 28 ++++++++++------------------ > 1 file changed, 10 insertions(+), 18 deletions(-) > > diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c > index 89d13e0705fe7b..0179a73a3fa2c4 100644 > --- a/fs/ocfs2/cluster/heartbeat.c > +++ b/fs/ocfs2/cluster/heartbeat.c > @@ -1766,7 +1766,6 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, > int sectsize; > char *p = (char *)page; > struct fd f; > - struct inode *inode; > ssize_t ret = -EINVAL; > int live_threshold; > > @@ -1793,20 +1792,16 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, > reg->hr_block_bytes == 0) > goto out2; > > - inode = igrab(f.file->f_mapping->host); > - if (inode == NULL) > + if (!S_ISBLK(f.file->f_mapping->host->i_mode)) > goto out2; > > - if (!S_ISBLK(inode->i_mode)) > - goto out3; > - > - reg->hr_bdev = I_BDEV(f.file->f_mapping->host); > - ret = blkdev_get(reg->hr_bdev, FMODE_WRITE | FMODE_READ, NULL); > - if (ret) { > + reg->hr_bdev = blkdev_get_by_dev(f.file->f_mapping->host->i_rdev, > + FMODE_WRITE | FMODE_READ, NULL); > + if (IS_ERR(reg->hr_bdev)) { > + ret = PTR_ERR(reg->hr_bdev); > reg->hr_bdev = NULL; > - goto out3; > + goto out2; > } > - inode = NULL; > > bdevname(reg->hr_bdev, reg->hr_dev_name); > > @@ -1909,16 +1904,13 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, > config_item_name(®->hr_item), reg->hr_dev_name); > > out3: > - iput(inode); > + if (ret < 0) { > + blkdev_put(reg->hr_bdev, FMODE_READ | FMODE_WRITE); > + reg->hr_bdev = NULL; > + } > out2: > fdput(f); > out: > - if (ret < 0) { > - if (reg->hr_bdev) { > - blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); > - reg->hr_bdev = NULL; > - } > - } > return ret; > } > >
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 89d13e0705fe7b..0179a73a3fa2c4 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -1766,7 +1766,6 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, int sectsize; char *p = (char *)page; struct fd f; - struct inode *inode; ssize_t ret = -EINVAL; int live_threshold; @@ -1793,20 +1792,16 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, reg->hr_block_bytes == 0) goto out2; - inode = igrab(f.file->f_mapping->host); - if (inode == NULL) + if (!S_ISBLK(f.file->f_mapping->host->i_mode)) goto out2; - if (!S_ISBLK(inode->i_mode)) - goto out3; - - reg->hr_bdev = I_BDEV(f.file->f_mapping->host); - ret = blkdev_get(reg->hr_bdev, FMODE_WRITE | FMODE_READ, NULL); - if (ret) { + reg->hr_bdev = blkdev_get_by_dev(f.file->f_mapping->host->i_rdev, + FMODE_WRITE | FMODE_READ, NULL); + if (IS_ERR(reg->hr_bdev)) { + ret = PTR_ERR(reg->hr_bdev); reg->hr_bdev = NULL; - goto out3; + goto out2; } - inode = NULL; bdevname(reg->hr_bdev, reg->hr_dev_name); @@ -1909,16 +1904,13 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, config_item_name(®->hr_item), reg->hr_dev_name); out3: - iput(inode); + if (ret < 0) { + blkdev_put(reg->hr_bdev, FMODE_READ | FMODE_WRITE); + reg->hr_bdev = NULL; + } out2: fdput(f); out: - if (ret < 0) { - if (reg->hr_bdev) { - blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); - reg->hr_bdev = NULL; - } - } return ret; }
Use blkdev_get_by_dev instead of igrab (aka open coded bdgrab) + blkdev_get. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/ocfs2/cluster/heartbeat.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)