hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/scsi/sd.h
....@@ -75,14 +75,22 @@
7575 struct opal_dev *opal_dev;
7676 #ifdef CONFIG_BLK_DEV_ZONED
7777 u32 nr_zones;
78
+ u32 rev_nr_zones;
7879 u32 zone_blocks;
79
- u32 zone_shift;
80
+ u32 rev_zone_blocks;
8081 u32 zones_optimal_open;
8182 u32 zones_optimal_nonseq;
8283 u32 zones_max_open;
84
+ u32 *zones_wp_offset;
85
+ spinlock_t zones_wp_offset_lock;
86
+ u32 *rev_wp_offset;
87
+ struct mutex rev_mutex;
88
+ struct work_struct zone_wp_offset_work;
89
+ char *zone_wp_update_buf;
8390 #endif
8491 atomic_t openers;
8592 sector_t capacity; /* size in logical blocks */
93
+ int max_retries;
8694 u32 max_xfer_blocks;
8795 u32 opt_xfer_blocks;
8896 u32 max_ws_blocks;
....@@ -136,7 +144,7 @@
136144
137145 #define sd_first_printk(prefix, sdsk, fmt, a...) \
138146 do { \
139
- if ((sdkp)->first_scan) \
147
+ if ((sdsk)->first_scan) \
140148 sd_printk(prefix, sdsk, fmt, ##a); \
141149 } while (0)
142150
....@@ -192,68 +200,6 @@
192200 return sector >> (ilog2(sdev->sector_size) - 9);
193201 }
194202
195
-/*
196
- * Look up the DIX operation based on whether the command is read or
197
- * write and whether dix and dif are enabled.
198
- */
199
-static inline unsigned int sd_prot_op(bool write, bool dix, bool dif)
200
-{
201
- /* Lookup table: bit 2 (write), bit 1 (dix), bit 0 (dif) */
202
- const unsigned int ops[] = { /* wrt dix dif */
203
- SCSI_PROT_NORMAL, /* 0 0 0 */
204
- SCSI_PROT_READ_STRIP, /* 0 0 1 */
205
- SCSI_PROT_READ_INSERT, /* 0 1 0 */
206
- SCSI_PROT_READ_PASS, /* 0 1 1 */
207
- SCSI_PROT_NORMAL, /* 1 0 0 */
208
- SCSI_PROT_WRITE_INSERT, /* 1 0 1 */
209
- SCSI_PROT_WRITE_STRIP, /* 1 1 0 */
210
- SCSI_PROT_WRITE_PASS, /* 1 1 1 */
211
- };
212
-
213
- return ops[write << 2 | dix << 1 | dif];
214
-}
215
-
216
-/*
217
- * Returns a mask of the protection flags that are valid for a given DIX
218
- * operation.
219
- */
220
-static inline unsigned int sd_prot_flag_mask(unsigned int prot_op)
221
-{
222
- const unsigned int flag_mask[] = {
223
- [SCSI_PROT_NORMAL] = 0,
224
-
225
- [SCSI_PROT_READ_STRIP] = SCSI_PROT_TRANSFER_PI |
226
- SCSI_PROT_GUARD_CHECK |
227
- SCSI_PROT_REF_CHECK |
228
- SCSI_PROT_REF_INCREMENT,
229
-
230
- [SCSI_PROT_READ_INSERT] = SCSI_PROT_REF_INCREMENT |
231
- SCSI_PROT_IP_CHECKSUM,
232
-
233
- [SCSI_PROT_READ_PASS] = SCSI_PROT_TRANSFER_PI |
234
- SCSI_PROT_GUARD_CHECK |
235
- SCSI_PROT_REF_CHECK |
236
- SCSI_PROT_REF_INCREMENT |
237
- SCSI_PROT_IP_CHECKSUM,
238
-
239
- [SCSI_PROT_WRITE_INSERT] = SCSI_PROT_TRANSFER_PI |
240
- SCSI_PROT_REF_INCREMENT,
241
-
242
- [SCSI_PROT_WRITE_STRIP] = SCSI_PROT_GUARD_CHECK |
243
- SCSI_PROT_REF_CHECK |
244
- SCSI_PROT_REF_INCREMENT |
245
- SCSI_PROT_IP_CHECKSUM,
246
-
247
- [SCSI_PROT_WRITE_PASS] = SCSI_PROT_TRANSFER_PI |
248
- SCSI_PROT_GUARD_CHECK |
249
- SCSI_PROT_REF_CHECK |
250
- SCSI_PROT_REF_INCREMENT |
251
- SCSI_PROT_IP_CHECKSUM,
252
- };
253
-
254
- return flag_mask[prot_op];
255
-}
256
-
257203 #ifdef CONFIG_BLK_DEV_INTEGRITY
258204
259205 extern void sd_dif_config_host(struct scsi_disk *);
....@@ -273,15 +219,22 @@
273219
274220 #ifdef CONFIG_BLK_DEV_ZONED
275221
276
-extern int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer);
277
-extern void sd_zbc_remove(struct scsi_disk *sdkp);
278
-extern void sd_zbc_print_zones(struct scsi_disk *sdkp);
279
-extern int sd_zbc_setup_report_cmnd(struct scsi_cmnd *cmd);
280
-extern int sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd);
281
-extern void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
282
- struct scsi_sense_hdr *sshdr);
222
+void sd_zbc_release_disk(struct scsi_disk *sdkp);
223
+int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer);
224
+int sd_zbc_revalidate_zones(struct scsi_disk *sdkp);
225
+blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd,
226
+ unsigned char op, bool all);
227
+unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
228
+ struct scsi_sense_hdr *sshdr);
229
+int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,
230
+ unsigned int nr_zones, report_zones_cb cb, void *data);
231
+
232
+blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba,
233
+ unsigned int nr_blocks);
283234
284235 #else /* CONFIG_BLK_DEV_ZONED */
236
+
237
+static inline void sd_zbc_release_disk(struct scsi_disk *sdkp) {}
285238
286239 static inline int sd_zbc_read_zones(struct scsi_disk *sdkp,
287240 unsigned char *buf)
....@@ -289,24 +242,36 @@
289242 return 0;
290243 }
291244
292
-static inline void sd_zbc_remove(struct scsi_disk *sdkp) {}
293
-
294
-static inline void sd_zbc_print_zones(struct scsi_disk *sdkp) {}
295
-
296
-static inline int sd_zbc_setup_report_cmnd(struct scsi_cmnd *cmd)
245
+static inline int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
297246 {
298
- return BLKPREP_INVALID;
247
+ return 0;
299248 }
300249
301
-static inline int sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd)
250
+static inline blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd,
251
+ unsigned char op,
252
+ bool all)
302253 {
303
- return BLKPREP_INVALID;
254
+ return BLK_STS_TARGET;
304255 }
305256
306
-static inline void sd_zbc_complete(struct scsi_cmnd *cmd,
307
- unsigned int good_bytes,
308
- struct scsi_sense_hdr *sshdr) {}
257
+static inline unsigned int sd_zbc_complete(struct scsi_cmnd *cmd,
258
+ unsigned int good_bytes, struct scsi_sense_hdr *sshdr)
259
+{
260
+ return good_bytes;
261
+}
262
+
263
+static inline blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd,
264
+ sector_t *lba,
265
+ unsigned int nr_blocks)
266
+{
267
+ return BLK_STS_TARGET;
268
+}
269
+
270
+#define sd_zbc_report_zones NULL
309271
310272 #endif /* CONFIG_BLK_DEV_ZONED */
311273
274
+void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr);
275
+void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result);
276
+
312277 #endif /* _SCSI_DISK_H */