@@ -100,103 +100,65 @@ queue_ra_store(struct request_queue *q, const char *page, size_t count)
100
100
return ret ;
101
101
}
102
102
103
- static ssize_t queue_max_sectors_show (struct request_queue * q , char * page )
104
- {
105
- int max_sectors_kb = queue_max_sectors (q ) >> 1 ;
106
-
107
- return queue_var_show (max_sectors_kb , page );
108
- }
109
-
110
- static ssize_t queue_max_segments_show (struct request_queue * q , char * page )
111
- {
112
- return queue_var_show (queue_max_segments (q ), page );
113
- }
114
-
115
- static ssize_t queue_max_discard_segments_show (struct request_queue * q ,
116
- char * page )
117
- {
118
- return queue_var_show (queue_max_discard_segments (q ), page );
119
- }
120
-
121
- static ssize_t queue_atomic_write_max_bytes_show (struct request_queue * q ,
122
- char * page )
123
- {
124
- return queue_var_show (queue_atomic_write_max_bytes (q ), page );
125
- }
126
-
127
- static ssize_t queue_atomic_write_boundary_show (struct request_queue * q ,
128
- char * page )
129
- {
130
- return queue_var_show (queue_atomic_write_boundary_bytes (q ), page );
131
- }
132
-
133
- static ssize_t queue_atomic_write_unit_min_show (struct request_queue * q ,
134
- char * page )
135
- {
136
- return queue_var_show (queue_atomic_write_unit_min_bytes (q ), page );
137
- }
138
-
139
- static ssize_t queue_atomic_write_unit_max_show (struct request_queue * q ,
140
- char * page )
141
- {
142
- return queue_var_show (queue_atomic_write_unit_max_bytes (q ), page );
143
- }
144
-
145
- static ssize_t queue_max_integrity_segments_show (struct request_queue * q , char * page )
146
- {
147
- return queue_var_show (q -> limits .max_integrity_segments , page );
148
- }
149
-
150
- static ssize_t queue_max_segment_size_show (struct request_queue * q , char * page )
151
- {
152
- return queue_var_show (queue_max_segment_size (q ), page );
153
- }
154
-
155
- static ssize_t queue_logical_block_size_show (struct request_queue * q , char * page )
156
- {
157
- return queue_var_show (queue_logical_block_size (q ), page );
158
- }
159
-
160
- static ssize_t queue_physical_block_size_show (struct request_queue * q , char * page )
161
- {
162
- return queue_var_show (queue_physical_block_size (q ), page );
163
- }
164
-
165
- static ssize_t queue_chunk_sectors_show (struct request_queue * q , char * page )
166
- {
167
- return queue_var_show (q -> limits .chunk_sectors , page );
168
- }
169
-
170
- static ssize_t queue_io_min_show (struct request_queue * q , char * page )
171
- {
172
- return queue_var_show (queue_io_min (q ), page );
173
- }
174
-
175
- static ssize_t queue_io_opt_show (struct request_queue * q , char * page )
176
- {
177
- return queue_var_show (queue_io_opt (q ), page );
178
- }
179
-
180
- static ssize_t queue_discard_granularity_show (struct request_queue * q , char * page )
181
- {
182
- return queue_var_show (q -> limits .discard_granularity , page );
103
+ #define QUEUE_SYSFS_LIMIT_SHOW (_field ) \
104
+ static ssize_t queue_##_field##_show(struct request_queue *q, char *page) \
105
+ { \
106
+ return queue_var_show(q->limits._field, page); \
107
+ }
108
+
109
+ QUEUE_SYSFS_LIMIT_SHOW (max_segments )
110
+ QUEUE_SYSFS_LIMIT_SHOW (max_discard_segments )
111
+ QUEUE_SYSFS_LIMIT_SHOW (max_integrity_segments )
112
+ QUEUE_SYSFS_LIMIT_SHOW (max_segment_size )
113
+ QUEUE_SYSFS_LIMIT_SHOW (logical_block_size )
114
+ QUEUE_SYSFS_LIMIT_SHOW (physical_block_size )
115
+ QUEUE_SYSFS_LIMIT_SHOW (chunk_sectors )
116
+ QUEUE_SYSFS_LIMIT_SHOW (io_min )
117
+ QUEUE_SYSFS_LIMIT_SHOW (io_opt )
118
+ QUEUE_SYSFS_LIMIT_SHOW (discard_granularity )
119
+ QUEUE_SYSFS_LIMIT_SHOW (zone_write_granularity )
120
+ QUEUE_SYSFS_LIMIT_SHOW (virt_boundary_mask )
121
+ QUEUE_SYSFS_LIMIT_SHOW (dma_alignment )
122
+ QUEUE_SYSFS_LIMIT_SHOW (max_open_zones )
123
+ QUEUE_SYSFS_LIMIT_SHOW (max_active_zones )
124
+ QUEUE_SYSFS_LIMIT_SHOW (atomic_write_unit_min )
125
+ QUEUE_SYSFS_LIMIT_SHOW (atomic_write_unit_max )
126
+
127
+ #define QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES (_field ) \
128
+ static ssize_t queue_ ##_field ##_show (struct request_queue * q , char * page ) \
129
+ { \
130
+ return sprintf (page , "%llu\n" , \
131
+ (unsigned long long )q -> limits ._field << SECTOR_SHIFT ); \
132
+ }
133
+
134
+ QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES (max_discard_sectors )
135
+ QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES (max_hw_discard_sectors )
136
+ QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES (max_write_zeroes_sectors )
137
+ QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES (atomic_write_max_sectors )
138
+ QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES (atomic_write_boundary_sectors )
139
+
140
+ #define QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_KB (_field ) \
141
+ static ssize_t queue_ ##_field ##_show (struct request_queue * q , char * page ) \
142
+ { \
143
+ return queue_var_show (q -> limits ._field >> 1 , page ); \
144
+ }
145
+
146
+ QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_KB (max_sectors )
147
+ QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_KB (max_hw_sectors )
148
+
149
+ #define QUEUE_SYSFS_SHOW_CONST (_name , _val ) \
150
+ static ssize_t queue_##_name##_show(struct request_queue *q, char *page) \
151
+ { \
152
+ return sprintf(page, "%d\n", _val); \
183
153
}
184
154
185
- static ssize_t queue_discard_max_hw_show (struct request_queue * q , char * page )
186
- {
187
-
188
- return sprintf (page , "%llu\n" ,
189
- (unsigned long long )q -> limits .max_hw_discard_sectors << 9 );
190
- }
155
+ /* deprecated fields */
156
+ QUEUE_SYSFS_SHOW_CONST (discard_zeroes_data , 0 )
157
+ QUEUE_SYSFS_SHOW_CONST (write_same_max , 0 )
158
+ QUEUE_SYSFS_SHOW_CONST (poll_delay , -1 )
191
159
192
- static ssize_t queue_discard_max_show (struct request_queue * q , char * page )
193
- {
194
- return sprintf (page , "%llu\n" ,
195
- (unsigned long long )q -> limits .max_discard_sectors << 9 );
196
- }
197
-
198
- static ssize_t queue_discard_max_store (struct request_queue * q ,
199
- const char * page , size_t count )
160
+ static ssize_t queue_max_discard_sectors_store (struct request_queue * q ,
161
+ const char * page , size_t count )
200
162
{
201
163
unsigned long max_discard_bytes ;
202
164
struct queue_limits lim ;
@@ -221,28 +183,11 @@ static ssize_t queue_discard_max_store(struct request_queue *q,
221
183
return ret ;
222
184
}
223
185
224
- static ssize_t queue_discard_zeroes_data_show (struct request_queue * q , char * page )
225
- {
226
- return queue_var_show (0 , page );
227
- }
228
-
229
- static ssize_t queue_write_same_max_show (struct request_queue * q , char * page )
230
- {
231
- return queue_var_show (0 , page );
232
- }
233
-
234
- static ssize_t queue_write_zeroes_max_show (struct request_queue * q , char * page )
235
- {
236
- return sprintf (page , "%llu\n" ,
237
- (unsigned long long )q -> limits .max_write_zeroes_sectors << 9 );
238
- }
239
-
240
- static ssize_t queue_zone_write_granularity_show (struct request_queue * q ,
241
- char * page )
242
- {
243
- return queue_var_show (queue_zone_write_granularity (q ), page );
244
- }
245
-
186
+ /*
187
+ * For zone append queue_max_zone_append_sectors does not just return the
188
+ * underlying queue limits, but actually contains a calculation. Because of
189
+ * that we can't simply use QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES here.
190
+ */
246
191
static ssize_t queue_zone_append_max_show (struct request_queue * q , char * page )
247
192
{
248
193
unsigned long long max_sectors = queue_max_zone_append_sectors (q );
@@ -270,23 +215,6 @@ queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)
270
215
return ret ;
271
216
}
272
217
273
- static ssize_t queue_max_hw_sectors_show (struct request_queue * q , char * page )
274
- {
275
- int max_hw_sectors_kb = queue_max_hw_sectors (q ) >> 1 ;
276
-
277
- return queue_var_show (max_hw_sectors_kb , page );
278
- }
279
-
280
- static ssize_t queue_virt_boundary_mask_show (struct request_queue * q , char * page )
281
- {
282
- return queue_var_show (q -> limits .virt_boundary_mask , page );
283
- }
284
-
285
- static ssize_t queue_dma_alignment_show (struct request_queue * q , char * page )
286
- {
287
- return queue_var_show (queue_dma_alignment (q ), page );
288
- }
289
-
290
218
static ssize_t queue_feature_store (struct request_queue * q , const char * page ,
291
219
size_t count , blk_features_t feature )
292
220
{
@@ -325,6 +253,16 @@ QUEUE_SYSFS_FEATURE(add_random, BLK_FEAT_ADD_RANDOM)
325
253
QUEUE_SYSFS_FEATURE (iostats , BLK_FEAT_IO_STAT )
326
254
QUEUE_SYSFS_FEATURE (stable_writes , BLK_FEAT_STABLE_WRITES );
327
255
256
+ #define QUEUE_SYSFS_FEATURE_SHOW (_name , _feature ) \
257
+ static ssize_t queue_##_name##_show(struct request_queue *q, char *page) \
258
+ { \
259
+ return sprintf(page, "%u\n", !!(q->limits.features & _feature)); \
260
+ }
261
+
262
+ QUEUE_SYSFS_FEATURE_SHOW (poll , BLK_FEAT_POLL );
263
+ QUEUE_SYSFS_FEATURE_SHOW (fua , BLK_FEAT_FUA );
264
+ QUEUE_SYSFS_FEATURE_SHOW (dax , BLK_FEAT_DAX );
265
+
328
266
static ssize_t queue_zoned_show (struct request_queue * q , char * page )
329
267
{
330
268
if (blk_queue_is_zoned (q ))
@@ -337,16 +275,6 @@ static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
337
275
return queue_var_show (disk_nr_zones (q -> disk ), page );
338
276
}
339
277
340
- static ssize_t queue_max_open_zones_show (struct request_queue * q , char * page )
341
- {
342
- return queue_var_show (bdev_max_open_zones (q -> disk -> part0 ), page );
343
- }
344
-
345
- static ssize_t queue_max_active_zones_show (struct request_queue * q , char * page )
346
- {
347
- return queue_var_show (bdev_max_active_zones (q -> disk -> part0 ), page );
348
- }
349
-
350
278
static ssize_t queue_nomerges_show (struct request_queue * q , char * page )
351
279
{
352
280
return queue_var_show ((blk_queue_nomerges (q ) << 1 ) |
@@ -405,22 +333,12 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
405
333
return ret ;
406
334
}
407
335
408
- static ssize_t queue_poll_delay_show (struct request_queue * q , char * page )
409
- {
410
- return sprintf (page , "%d\n" , -1 );
411
- }
412
-
413
336
static ssize_t queue_poll_delay_store (struct request_queue * q , const char * page ,
414
337
size_t count )
415
338
{
416
339
return count ;
417
340
}
418
341
419
- static ssize_t queue_poll_show (struct request_queue * q , char * page )
420
- {
421
- return queue_var_show (!!(q -> limits .features & BLK_FEAT_POLL ), page );
422
- }
423
-
424
342
static ssize_t queue_poll_store (struct request_queue * q , const char * page ,
425
343
size_t count )
426
344
{
@@ -485,16 +403,6 @@ static ssize_t queue_wc_store(struct request_queue *q, const char *page,
485
403
return count ;
486
404
}
487
405
488
- static ssize_t queue_fua_show (struct request_queue * q , char * page )
489
- {
490
- return sprintf (page , "%u\n" , !!(q -> limits .features & BLK_FEAT_FUA ));
491
- }
492
-
493
- static ssize_t queue_dax_show (struct request_queue * q , char * page )
494
- {
495
- return queue_var_show (!!blk_queue_dax (q ), page );
496
- }
497
-
498
406
#define QUEUE_RO_ENTRY (_prefix , _name ) \
499
407
static struct queue_sysfs_entry _prefix##_entry = { \
500
408
.attr = { .name = _name, .mode = 0444 }, \
@@ -525,17 +433,18 @@ QUEUE_RO_ENTRY(queue_io_opt, "optimal_io_size");
525
433
526
434
QUEUE_RO_ENTRY (queue_max_discard_segments , "max_discard_segments" );
527
435
QUEUE_RO_ENTRY (queue_discard_granularity , "discard_granularity" );
528
- QUEUE_RO_ENTRY (queue_discard_max_hw , "discard_max_hw_bytes" );
529
- QUEUE_RW_ENTRY (queue_discard_max , "discard_max_bytes" );
436
+ QUEUE_RO_ENTRY (queue_max_hw_discard_sectors , "discard_max_hw_bytes" );
437
+ QUEUE_RW_ENTRY (queue_max_discard_sectors , "discard_max_bytes" );
530
438
QUEUE_RO_ENTRY (queue_discard_zeroes_data , "discard_zeroes_data" );
531
439
532
- QUEUE_RO_ENTRY (queue_atomic_write_max_bytes , "atomic_write_max_bytes" );
533
- QUEUE_RO_ENTRY (queue_atomic_write_boundary , "atomic_write_boundary_bytes" );
440
+ QUEUE_RO_ENTRY (queue_atomic_write_max_sectors , "atomic_write_max_bytes" );
441
+ QUEUE_RO_ENTRY (queue_atomic_write_boundary_sectors ,
442
+ "atomic_write_boundary_bytes" );
534
443
QUEUE_RO_ENTRY (queue_atomic_write_unit_max , "atomic_write_unit_max_bytes" );
535
444
QUEUE_RO_ENTRY (queue_atomic_write_unit_min , "atomic_write_unit_min_bytes" );
536
445
537
446
QUEUE_RO_ENTRY (queue_write_same_max , "write_same_max_bytes" );
538
- QUEUE_RO_ENTRY (queue_write_zeroes_max , "write_zeroes_max_bytes" );
447
+ QUEUE_RO_ENTRY (queue_max_write_zeroes_sectors , "write_zeroes_max_bytes" );
539
448
QUEUE_RO_ENTRY (queue_zone_append_max , "zone_append_max_bytes" );
540
449
QUEUE_RO_ENTRY (queue_zone_write_granularity , "zone_write_granularity" );
541
450
@@ -652,15 +561,15 @@ static struct attribute *queue_attrs[] = {
652
561
& queue_io_min_entry .attr ,
653
562
& queue_io_opt_entry .attr ,
654
563
& queue_discard_granularity_entry .attr ,
655
- & queue_discard_max_entry .attr ,
656
- & queue_discard_max_hw_entry .attr ,
564
+ & queue_max_discard_sectors_entry .attr ,
565
+ & queue_max_hw_discard_sectors_entry .attr ,
657
566
& queue_discard_zeroes_data_entry .attr ,
658
- & queue_atomic_write_max_bytes_entry .attr ,
659
- & queue_atomic_write_boundary_entry .attr ,
567
+ & queue_atomic_write_max_sectors_entry .attr ,
568
+ & queue_atomic_write_boundary_sectors_entry .attr ,
660
569
& queue_atomic_write_unit_min_entry .attr ,
661
570
& queue_atomic_write_unit_max_entry .attr ,
662
571
& queue_write_same_max_entry .attr ,
663
- & queue_write_zeroes_max_entry .attr ,
572
+ & queue_max_write_zeroes_sectors_entry .attr ,
664
573
& queue_zone_append_max_entry .attr ,
665
574
& queue_zone_write_granularity_entry .attr ,
666
575
& queue_rotational_entry .attr ,
0 commit comments