History

block: integrity flags can't use bit ops on unsigned short

Just use normal open coded bit operations instead, they need not be atomic.

Jens Axboe committed 18 years ago

Commit b24498d1 parent 06a452e2 files · +11 −14Browse files

Unified · Split

2 files
  1. block/blk-integrity.c +7 −10
  2. include/linux/blkdev.h +4 −4
block/blk-integrity.c+7−10
@@ -217,17 +217,16 @@ static ssize_t integrity_read_store(struct blk_integrity *bi, · 216 unmodified lines
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 else221 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, · 3 unmodified lines
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 else240 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) · 86 unmodified lines
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 } else344 } else
include/linux/blkdev.h+4−4
@@ -870,8 +870,8 @@ void kblockd_flush_work(struct work_struct *work); · 869 unmodified lines
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) · 62 unmodified lines
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;