aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-integrity.c17
-rw-r--r--include/linux/blkdev.h8
2 files changed, 11 insertions, 14 deletions
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 4ffa3814f6a9..3f1a8478cc38 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -217,17 +217,16 @@ static ssize_t integrity_read_store(struct blk_integrity *bi,
217 unsigned long val = simple_strtoul(p, &p, 10); 217 unsigned long val = simple_strtoul(p, &p, 10);
218 218
219 if (val) 219 if (val)
220 set_bit(INTEGRITY_FLAG_READ, &bi->flags); 220 bi->flags |= INTEGRITY_FLAG_READ;
221 else 221 else
222 clear_bit(INTEGRITY_FLAG_READ, &bi->flags); 222 bi->flags &= ~INTEGRITY_FLAG_READ;
223 223
224 return count; 224 return count;
225} 225}
226 226
227static ssize_t integrity_read_show(struct blk_integrity *bi, char *page) 227static ssize_t integrity_read_show(struct blk_integrity *bi, char *page)
228{ 228{
229 return sprintf(page, "%d\n", 229 return sprintf(page, "%d\n", (bi->flags & INTEGRITY_FLAG_READ) != 0);
230 test_bit(INTEGRITY_FLAG_READ, &bi->flags) ? 1 : 0);
231} 230}
232 231
233static ssize_t integrity_write_store(struct blk_integrity *bi, 232static ssize_t integrity_write_store(struct blk_integrity *bi,
@@ -237,17 +236,16 @@ static ssize_t integrity_write_store(struct blk_integrity *bi,
237 unsigned long val = simple_strtoul(p, &p, 10); 236 unsigned long val = simple_strtoul(p, &p, 10);
238 237
239 if (val) 238 if (val)
240 set_bit(INTEGRITY_FLAG_WRITE, &bi->flags); 239 bi->flags |= INTEGRITY_FLAG_WRITE;
241 else 240 else
242 clear_bit(INTEGRITY_FLAG_WRITE, &bi->flags); 241 bi->flags &= ~INTEGRITY_FLAG_WRITE;
243 242
244 return count; 243 return count;
245} 244}
246 245
247static ssize_t integrity_write_show(struct blk_integrity *bi, char *page) 246static ssize_t integrity_write_show(struct blk_integrity *bi, char *page)
248{ 247{
249 return sprintf(page, "%d\n", 248 return sprintf(page, "%d\n", (bi->flags & INTEGRITY_FLAG_WRITE) != 0);
250 test_bit(INTEGRITY_FLAG_WRITE, &bi->flags) ? 1 : 0);
251} 249}
252 250
253static struct integrity_sysfs_entry integrity_format_entry = { 251static struct integrity_sysfs_entry integrity_format_entry = {
@@ -340,8 +338,7 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template)
340 338
341 kobject_uevent(&bi->kobj, KOBJ_ADD); 339 kobject_uevent(&bi->kobj, KOBJ_ADD);
342 340
343 set_bit(INTEGRITY_FLAG_READ, &bi->flags); 341 bi->flags |= INTEGRITY_FLAG_READ | INTEGRITY_FLAG_WRITE;
344 set_bit(INTEGRITY_FLAG_WRITE, &bi->flags);
345 bi->sector_size = disk->queue->hardsect_size; 342 bi->sector_size = disk->queue->hardsect_size;
346 disk->integrity = bi; 343 disk->integrity = bi;
347 } else 344 } else
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index a842b776d099..7ab8acad5b6e 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -870,8 +870,8 @@ void kblockd_flush_work(struct work_struct *work);
870 870
871#if defined(CONFIG_BLK_DEV_INTEGRITY) 871#if defined(CONFIG_BLK_DEV_INTEGRITY)
872 872
873#define INTEGRITY_FLAG_READ 1 /* verify data integrity on read */ 873#define INTEGRITY_FLAG_READ 2 /* verify data integrity on read */
874#define INTEGRITY_FLAG_WRITE 2 /* generate data integrity on write */ 874#define INTEGRITY_FLAG_WRITE 4 /* generate data integrity on write */
875 875
876struct blk_integrity_exchg { 876struct blk_integrity_exchg {
877 void *prot_buf; 877 void *prot_buf;
@@ -940,11 +940,11 @@ static inline int bdev_integrity_enabled(struct block_device *bdev, int rw)
940 return 0; 940 return 0;
941 941
942 if (rw == READ && bi->verify_fn != NULL && 942 if (rw == READ && bi->verify_fn != NULL &&
943 test_bit(INTEGRITY_FLAG_READ, &bi->flags)) 943 (bi->flags & INTEGRITY_FLAG_READ))
944 return 1; 944 return 1;
945 945
946 if (rw == WRITE && bi->generate_fn != NULL && 946 if (rw == WRITE && bi->generate_fn != NULL &&
947 test_bit(INTEGRITY_FLAG_WRITE, &bi->flags)) 947 (bi->flags & INTEGRITY_FLAG_WRITE))
948 return 1; 948 return 1;
949 949
950 return 0; 950 return 0;