提交 c3b9a62c 编写于 作者: C Christoph Hellwig 提交者: Jens Axboe

btrfs: replace barriers with explicit flush / FUA usage

Switch to the WRITE_FLUSH_FUA flag for log writes, remove the EOPNOTSUPP
detection for barriers and stop setting the barrier flag for discards.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Acked-by: NChris Mason <chris.mason@oracle.com>
Signed-off-by: NTejun Heo <tj@kernel.org>
Signed-off-by: NJens Axboe <jaxboe@fusionio.com>
上级 80f6c29d
...@@ -2063,7 +2063,7 @@ static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate) ...@@ -2063,7 +2063,7 @@ static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)
if (uptodate) { if (uptodate) {
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
} else { } else {
if (!buffer_eopnotsupp(bh) && printk_ratelimit()) { if (printk_ratelimit()) {
printk(KERN_WARNING "lost page write due to " printk(KERN_WARNING "lost page write due to "
"I/O error on %s\n", "I/O error on %s\n",
bdevname(bh->b_bdev, b)); bdevname(bh->b_bdev, b));
...@@ -2200,21 +2200,10 @@ static int write_dev_supers(struct btrfs_device *device, ...@@ -2200,21 +2200,10 @@ static int write_dev_supers(struct btrfs_device *device,
bh->b_end_io = btrfs_end_buffer_write_sync; bh->b_end_io = btrfs_end_buffer_write_sync;
} }
if (i == last_barrier && do_barriers && device->barriers) { if (i == last_barrier && do_barriers)
ret = submit_bh(WRITE_BARRIER, bh); ret = submit_bh(WRITE_FLUSH_FUA, bh);
if (ret == -EOPNOTSUPP) { else
printk("btrfs: disabling barriers on dev %s\n",
device->name);
set_buffer_uptodate(bh);
device->barriers = 0;
/* one reference for submit_bh */
get_bh(bh);
lock_buffer(bh);
ret = submit_bh(WRITE_SYNC, bh);
}
} else {
ret = submit_bh(WRITE_SYNC, bh); ret = submit_bh(WRITE_SYNC, bh);
}
if (ret) if (ret)
errors++; errors++;
......
...@@ -1696,7 +1696,7 @@ static void btrfs_issue_discard(struct block_device *bdev, ...@@ -1696,7 +1696,7 @@ static void btrfs_issue_discard(struct block_device *bdev,
u64 start, u64 len) u64 start, u64 len)
{ {
blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL, blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL,
BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER); BLKDEV_IFL_WAIT);
} }
static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
......
...@@ -398,7 +398,6 @@ static noinline int device_list_add(const char *path, ...@@ -398,7 +398,6 @@ static noinline int device_list_add(const char *path,
device->work.func = pending_bios_fn; device->work.func = pending_bios_fn;
memcpy(device->uuid, disk_super->dev_item.uuid, memcpy(device->uuid, disk_super->dev_item.uuid,
BTRFS_UUID_SIZE); BTRFS_UUID_SIZE);
device->barriers = 1;
spin_lock_init(&device->io_lock); spin_lock_init(&device->io_lock);
device->name = kstrdup(path, GFP_NOFS); device->name = kstrdup(path, GFP_NOFS);
if (!device->name) { if (!device->name) {
...@@ -462,7 +461,6 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig) ...@@ -462,7 +461,6 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
device->devid = orig_dev->devid; device->devid = orig_dev->devid;
device->work.func = pending_bios_fn; device->work.func = pending_bios_fn;
memcpy(device->uuid, orig_dev->uuid, sizeof(device->uuid)); memcpy(device->uuid, orig_dev->uuid, sizeof(device->uuid));
device->barriers = 1;
spin_lock_init(&device->io_lock); spin_lock_init(&device->io_lock);
INIT_LIST_HEAD(&device->dev_list); INIT_LIST_HEAD(&device->dev_list);
INIT_LIST_HEAD(&device->dev_alloc_list); INIT_LIST_HEAD(&device->dev_alloc_list);
...@@ -1489,7 +1487,6 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) ...@@ -1489,7 +1487,6 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
trans = btrfs_start_transaction(root, 0); trans = btrfs_start_transaction(root, 0);
lock_chunks(root); lock_chunks(root);
device->barriers = 1;
device->writeable = 1; device->writeable = 1;
device->work.func = pending_bios_fn; device->work.func = pending_bios_fn;
generate_random_uuid(device->uuid); generate_random_uuid(device->uuid);
...@@ -3084,7 +3081,6 @@ static struct btrfs_device *add_missing_dev(struct btrfs_root *root, ...@@ -3084,7 +3081,6 @@ static struct btrfs_device *add_missing_dev(struct btrfs_root *root,
return NULL; return NULL;
list_add(&device->dev_list, list_add(&device->dev_list,
&fs_devices->devices); &fs_devices->devices);
device->barriers = 1;
device->dev_root = root->fs_info->dev_root; device->dev_root = root->fs_info->dev_root;
device->devid = devid; device->devid = devid;
device->work.func = pending_bios_fn; device->work.func = pending_bios_fn;
......
...@@ -42,7 +42,6 @@ struct btrfs_device { ...@@ -42,7 +42,6 @@ struct btrfs_device {
int running_pending; int running_pending;
u64 generation; u64 generation;
int barriers;
int writeable; int writeable;
int in_fs_metadata; int in_fs_metadata;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册