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
217217 unsigned long val = simple_strtoul(p, &p, 10);
218218
219219 if (val)
220− set_bit(INTEGRITY_FLAG_READ, &bi->flags);
220+ bi->flags |= INTEGRITY_FLAG_READ;
221221 else
222− clear_bit(INTEGRITY_FLAG_READ, &bi->flags);
222+ bi->flags &= ~INTEGRITY_FLAG_READ;
223223
224224 return count;
225225 }
226226
227227 static ssize_t integrity_read_show(struct blk_integrity *bi, char *page)
228228 {
229− return sprintf(page, "%d\n",
230− test_bit(INTEGRITY_FLAG_READ, &bi->flags) ? 1 : 0);
229+ return sprintf(page, "%d\n", (bi->flags & INTEGRITY_FLAG_READ) != 0);
231230 }
232231
233232 static 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
237236 unsigned long val = simple_strtoul(p, &p, 10);
238237
239238 if (val)
240− set_bit(INTEGRITY_FLAG_WRITE, &bi->flags);
239+ bi->flags |= INTEGRITY_FLAG_WRITE;
241240 else
242− clear_bit(INTEGRITY_FLAG_WRITE, &bi->flags);
241+ bi->flags &= ~INTEGRITY_FLAG_WRITE;
243242
244243 return count;
245244 }
246245
247246 static ssize_t integrity_write_show(struct blk_integrity *bi, char *page)
248247 {
249− return sprintf(page, "%d\n",
250− test_bit(INTEGRITY_FLAG_WRITE, &bi->flags) ? 1 : 0);
248+ return sprintf(page, "%d\n", (bi->flags & INTEGRITY_FLAG_WRITE) != 0);
251249 }
252250
253251 static 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
340338
341339 kobject_uevent(&bi->kobj, KOBJ_ADD);
342340
343− set_bit(INTEGRITY_FLAG_READ, &bi->flags);
344− set_bit(INTEGRITY_FLAG_WRITE, &bi->flags);
341+ bi->flags |= INTEGRITY_FLAG_READ | INTEGRITY_FLAG_WRITE;
345342 bi->sector_size = disk->queue->hardsect_size;
346343 disk->integrity = bi;
347344 } else
include/linux/blkdev.h+4−4
@@ -870,8 +870,8 @@ void kblockd_flush_work(struct work_struct *work); · 869 unmodified lines
870870
871871 #if defined(CONFIG_BLK_DEV_INTEGRITY)
872872
873−#define INTEGRITY_FLAG_READ 1 /* verify data integrity on read */
874−#define INTEGRITY_FLAG_WRITE 2 /* generate data integrity on write */
873+#define INTEGRITY_FLAG_READ 2 /* verify data integrity on read */
874+#define INTEGRITY_FLAG_WRITE 4 /* generate data integrity on write */
875875
876876 struct blk_integrity_exchg {
877877 void *prot_buf;
@@ -940,11 +940,11 @@ static inline int bdev_integrity_enabled(struct block_device *bdev, int rw) · 62 unmodified lines
940940 return 0;
941941
942942 if (rw == READ && bi->verify_fn != NULL &&
943− test_bit(INTEGRITY_FLAG_READ, &bi->flags))
943+ (bi->flags & INTEGRITY_FLAG_READ))
944944 return 1;
945945
946946 if (rw == WRITE && bi->generate_fn != NULL &&
947− test_bit(INTEGRITY_FLAG_WRITE, &bi->flags))
947+ (bi->flags & INTEGRITY_FLAG_WRITE))
948948 return 1;
949949
950950 return 0;