Skip to content

Commit 07c4e1e

Browse files
Ming Leiaxboe
authored andcommitted
block: only define 'nr_sects_seq' in hd_part for 32bit SMP
The seqcount of 'nr_sects_seq' is only needed in case of 32bit SMP, so define it just for 32bit SMP. Signed-off-by: Ming Lei <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Cc: Yufen Yu <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Hou Tao <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent b7d6c30 commit 07c4e1e

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

block/genhd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ struct gendisk *__alloc_disk_node(int minors, int node_id)
17311731
* TODO: Ideally set_capacity() and get_capacity() should be
17321732
* converted to make use of bd_mutex and sequence counters.
17331733
*/
1734-
seqcount_init(&disk->part0.nr_sects_seq);
1734+
hd_sects_seq_init(&disk->part0);
17351735
if (hd_ref_init(&disk->part0)) {
17361736
hd_free_part(&disk->part0);
17371737
kfree(disk);

block/partitions/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static struct hd_struct *add_partition(struct gendisk *disk, int partno,
392392
goto out_free;
393393
}
394394

395-
seqcount_init(&p->nr_sects_seq);
395+
hd_sects_seq_init(p);
396396
pdev = part_to_dev(p);
397397

398398
p->start_sect = start;

include/linux/genhd.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ struct hd_struct {
6868
* can be non-atomic on 32bit machines with 64bit sector_t.
6969
*/
7070
sector_t nr_sects;
71+
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
7172
seqcount_t nr_sects_seq;
73+
#endif
7274
sector_t alignment_offset;
7375
unsigned int discard_alignment;
7476
struct device __dev;
@@ -274,6 +276,13 @@ static inline void disk_put_part(struct hd_struct *part)
274276
put_device(part_to_dev(part));
275277
}
276278

279+
static inline void hd_sects_seq_init(struct hd_struct *p)
280+
{
281+
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
282+
seqcount_init(&p->nr_sects_seq);
283+
#endif
284+
}
285+
277286
/*
278287
* Smarter partition iterator without context limits.
279288
*/

0 commit comments

Comments
 (0)