summaryrefslogtreecommitdiff
path: root/include/linux/genhd.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-11-26 18:43:37 +0100
committerJens Axboe <axboe@kernel.dk>2020-12-01 14:53:40 -0700
commita782483cc1f875355690625d8253a232f2581418 (patch)
tree492d3bf67cdd2535afd826dde93aa35dcfb42180 /include/linux/genhd.h
parente6cb53827ed60019bbbc5cf189dd204b3b0e8121 (diff)
block: remove the nr_sects field in struct hd_struct
Now that the hd_struct always has a block device attached to it, there is no need for having two size field that just get out of sync. Additionally the field in hd_struct did not use proper serialization, possibly allowing for torn writes. By only using the block_device field this problem also gets fixed. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Hannes Reinecke <hare@suse.de> Acked-by: Coly Li <colyli@suse.de> [bcache] Acked-by: Chao Yu <yuchao0@huawei.com> [f2fs] Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r--include/linux/genhd.h29
1 files changed, 7 insertions, 22 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 6ba91ee54cb2..30d4785b7df8 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -52,15 +52,6 @@ struct partition_meta_info {
struct hd_struct {
sector_t start_sect;
- /*
- * nr_sects is protected by sequence counter. One might extend a
- * partition while IO is happening to it and update of nr_sects
- * can be non-atomic on 32bit machines with 64bit sector_t.
- */
- sector_t nr_sects;
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- seqcount_t nr_sects_seq;
-#endif
unsigned long stamp;
struct disk_stats __percpu *dkstats;
struct percpu_ref ref;
@@ -254,13 +245,6 @@ static inline void disk_put_part(struct hd_struct *part)
put_device(part_to_dev(part));
}
-static inline void hd_sects_seq_init(struct hd_struct *p)
-{
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- seqcount_init(&p->nr_sects_seq);
-#endif
-}
-
/*
* Smarter partition iterator without context limits.
*/
@@ -318,13 +302,15 @@ static inline sector_t get_start_sect(struct block_device *bdev)
{
return bdev->bd_part->start_sect;
}
-static inline sector_t get_capacity(struct gendisk *disk)
+
+static inline sector_t bdev_nr_sectors(struct block_device *bdev)
{
- return disk->part0.nr_sects;
+ return i_size_read(bdev->bd_inode) >> 9;
}
-static inline void set_capacity(struct gendisk *disk, sector_t size)
+
+static inline sector_t get_capacity(struct gendisk *disk)
{
- disk->part0.nr_sects = size;
+ return bdev_nr_sectors(disk->part0.bdev);
}
int bdev_disk_changed(struct block_device *bdev, bool invalidate);
@@ -358,10 +344,9 @@ int __register_blkdev(unsigned int major, const char *name,
__register_blkdev(major, name, NULL)
void unregister_blkdev(unsigned int major, const char *name);
-void revalidate_disk_size(struct gendisk *disk, bool verbose);
bool bdev_check_media_change(struct block_device *bdev);
int __invalidate_device(struct block_device *bdev, bool kill_dirty);
-void bd_set_nr_sectors(struct block_device *bdev, sector_t sectors);
+void set_capacity(struct gendisk *disk, sector_t size);
/* for drivers/char/raw.c: */
int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);