From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk,
Nicholas Bellinger <nab@linux-iscsi.org>,
Christoph Hellwig <hch@lst.de>
Subject: [ 76/82] target/file: Use O_DSYNC by default for FILEIO backends
Date: Fri, 08 Jun 2012 05:19:56 +0100 [thread overview]
Message-ID: <20120608041851.096743193@decadent.org.uk> (raw)
In-Reply-To: <20120608041840.861504477@decadent.org.uk>
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <nab@linux-iscsi.org>
commit a4dff3043c231d57f982af635c9d2192ee40e5ae upstream.
Convert to use O_DSYNC for all cases at FILEIO backend creation time to
avoid the extra syncing of pure timestamp updates with legacy O_SYNC during
default operation as recommended by hch. Continue to do this independently of
Write Cache Enable (WCE) bit, as WCE=0 is currently the default for all backend
devices and enabled by user on per device basis via attrib/emulate_write_cache.
This patch drops the now unnecessary fd_buffered_io= token usage that was
originally signalling when to explictly disable O_SYNC at backend creation
time for buffered I/O operation. This can end up being dangerous for a number
of reasons during physical node failure, so go ahead and drop this option
for now when O_DSYNC is used as the default.
Also allow explict FUA WRITEs -> vfs_fsync_range() call to function in
fd_execute_cmd() independently of WCE bit setting.
Reported-by: Christoph Hellwig <hch@lst.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[bwh: Backported to 3.2:
- We have fd_do_task() and not fd_execute_cmd()
- Various fields are in struct se_task rather than struct se_cmd
- fd_create_virtdevice() flags initialisation hasn't been cleaned up]
---
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -134,21 +134,11 @@
ret = PTR_ERR(dev_p);
goto fail;
}
-#if 0
- if (di->no_create_file)
- flags = O_RDWR | O_LARGEFILE;
- else
- flags = O_RDWR | O_CREAT | O_LARGEFILE;
-#else
- flags = O_RDWR | O_CREAT | O_LARGEFILE;
-#endif
-/* flags |= O_DIRECT; */
/*
- * If fd_buffered_io=1 has not been set explicitly (the default),
- * use O_SYNC to force FILEIO writes to disk.
+ * Use O_DSYNC by default instead of O_SYNC to forgo syncing
+ * of pure timestamp updates.
*/
- if (!(fd_dev->fbd_flags & FDBD_USE_BUFFERED_IO))
- flags |= O_SYNC;
+ flags = O_RDWR | O_CREAT | O_LARGEFILE | O_DSYNC;
file = filp_open(dev_p, flags, 0600);
if (IS_ERR(file)) {
@@ -400,26 +390,6 @@
transport_complete_sync_cache(cmd, ret == 0);
}
-/*
- * WRITE Force Unit Access (FUA) emulation on a per struct se_task
- * LBA range basis..
- */
-static void fd_emulate_write_fua(struct se_cmd *cmd, struct se_task *task)
-{
- struct se_device *dev = cmd->se_dev;
- struct fd_dev *fd_dev = dev->dev_ptr;
- loff_t start = task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
- loff_t end = start + task->task_size;
- int ret;
-
- pr_debug("FILEIO: FUA WRITE LBA: %llu, bytes: %u\n",
- task->task_lba, task->task_size);
-
- ret = vfs_fsync_range(fd_dev->fd_file, start, end, 1);
- if (ret != 0)
- pr_err("FILEIO: vfs_fsync_range() failed: %d\n", ret);
-}
-
static int fd_do_task(struct se_task *task)
{
struct se_cmd *cmd = task->task_se_cmd;
@@ -434,19 +404,21 @@
ret = fd_do_readv(task);
} else {
ret = fd_do_writev(task);
-
+ /*
+ * Perform implict vfs_fsync_range() for fd_do_writev() ops
+ * for SCSI WRITEs with Forced Unit Access (FUA) set.
+ * Allow this to happen independent of WCE=0 setting.
+ */
if (ret > 0 &&
- dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0 &&
dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0 &&
(cmd->se_cmd_flags & SCF_FUA)) {
- /*
- * We might need to be a bit smarter here
- * and return some sense data to let the initiator
- * know the FUA WRITE cache sync failed..?
- */
- fd_emulate_write_fua(cmd, task);
- }
+ struct fd_dev *fd_dev = dev->dev_ptr;
+ loff_t start = task->task_lba *
+ dev->se_sub_dev->se_dev_attrib.block_size;
+ loff_t end = start + task->task_size;
+ vfs_fsync_range(fd_dev->fd_file, start, end, 1);
+ }
}
if (ret < 0) {
@@ -478,7 +450,6 @@
static match_table_t tokens = {
{Opt_fd_dev_name, "fd_dev_name=%s"},
{Opt_fd_dev_size, "fd_dev_size=%s"},
- {Opt_fd_buffered_io, "fd_buffered_io=%d"},
{Opt_err, NULL}
};
@@ -490,7 +461,7 @@
struct fd_dev *fd_dev = se_dev->se_dev_su_ptr;
char *orig, *ptr, *arg_p, *opts;
substring_t args[MAX_OPT_ARGS];
- int ret = 0, arg, token;
+ int ret = 0, token;
opts = kstrdup(page, GFP_KERNEL);
if (!opts)
@@ -534,19 +505,6 @@
" bytes\n", fd_dev->fd_dev_size);
fd_dev->fbd_flags |= FBDF_HAS_SIZE;
break;
- case Opt_fd_buffered_io:
- match_int(args, &arg);
- if (arg != 1) {
- pr_err("bogus fd_buffered_io=%d value\n", arg);
- ret = -EINVAL;
- goto out;
- }
-
- pr_debug("FILEIO: Using buffered I/O"
- " operations for struct fd_dev\n");
-
- fd_dev->fbd_flags |= FDBD_USE_BUFFERED_IO;
- break;
default:
break;
}
@@ -578,10 +536,8 @@
ssize_t bl = 0;
bl = sprintf(b + bl, "TCM FILEIO ID: %u", fd_dev->fd_dev_id);
- bl += sprintf(b + bl, " File: %s Size: %llu Mode: %s\n",
- fd_dev->fd_dev_name, fd_dev->fd_dev_size,
- (fd_dev->fbd_flags & FDBD_USE_BUFFERED_IO) ?
- "Buffered" : "Synchronous");
+ bl += sprintf(b + bl, " File: %s Size: %llu Mode: O_DSYNC\n",
+ fd_dev->fd_dev_name, fd_dev->fd_dev_size);
return bl;
}
--- a/drivers/target/target_core_file.h
+++ b/drivers/target/target_core_file.h
@@ -18,7 +18,6 @@
#define FBDF_HAS_PATH 0x01
#define FBDF_HAS_SIZE 0x02
-#define FDBD_USE_BUFFERED_IO 0x04
struct fd_dev {
u32 fbd_flags;
next prev parent reply other threads:[~2012-06-08 4:19 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-08 4:18 [ 00/82] 3.2.20-stable review Ben Hutchings
2012-06-08 4:18 ` [ 01/82] iommu/amd: Add workaround for event log erratum Ben Hutchings
2012-06-08 4:18 ` [ 02/82] MIPS: BCM63XX: Add missing include for bcm63xx_gpio.h Ben Hutchings
2012-06-08 4:18 ` [ 03/82] cifs: Include backup intent search flags during searches {try #2) Ben Hutchings
2012-06-08 4:18 ` [ 04/82] sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot Ben Hutchings
2012-06-08 4:18 ` [ 05/82] exofs: Fix CRASH on very early IO errors Ben Hutchings
2012-06-08 4:18 ` [ 06/82] cifs: fix oops while traversing open file list (try #4) Ben Hutchings
2012-06-08 4:18 ` [ 07/82] [SCSI] Fix dm-multipath starvation when scsi host is busy Ben Hutchings
2012-06-08 4:18 ` [ 08/82] ixp4xx: fix compilation by adding gpiolib support Ben Hutchings
2012-06-08 4:18 ` [ 09/82] drm/i915: properly handle interlaced bit for sdvo dtd conversion Ben Hutchings
2012-06-08 4:18 ` [ 10/82] drm/i915: enable vdd when switching off the eDP panel Ben Hutchings
2012-06-08 4:18 ` [ 11/82] drm/i915: Add Clientron E830 to the ignore LVDS list Ben Hutchings
2012-06-08 4:18 ` [ 12/82] drm/i915: Ignore LVDS on hp t5745 and hp st5747 thin client Ben Hutchings
2012-06-08 4:18 ` [ 13/82] drm/i915: no lvds quirk for HP t5740e Thin Client Ben Hutchings
2012-06-08 4:18 ` [ 14/82] drm/i915: wait for a vblank to pass after tv detect Ben Hutchings
2012-06-08 4:18 ` [ 15/82] drm/i915: Update GEN6_RP_CONTROL definitions Ben Hutchings
2012-06-08 4:18 ` [ 16/82] drm/i915: always use RPNSWREQ for turbo change requests Ben Hutchings
2012-06-08 4:18 ` [ 17/82] solos-pci: Fix DMA support Ben Hutchings
2012-06-08 4:18 ` [ 18/82] microblaze: Do not select GENERIC_GPIO by default Ben Hutchings
2012-06-08 4:18 ` [ 19/82] [PARISC] fix boot failure on 32-bit systems caused by branch stubs placed before .text Ben Hutchings
2012-06-08 4:19 ` [ 20/82] [PARISC] fix TLB fault path on PA2.0 narrow systems Ben Hutchings
2012-06-08 4:19 ` [ 21/82] iwlwifi: update BT traffic load states correctly Ben Hutchings
2012-06-08 4:19 ` [ 22/82] iwlwifi: do not use shadow registers by default Ben Hutchings
2012-06-08 4:19 ` [ 23/82] wl1251: fix oops on early interrupt Ben Hutchings
2012-06-08 4:19 ` [ 24/82] NFSv4: Map NFS4ERR_SHARE_DENIED into an EACCES error instead of EIO Ben Hutchings
2012-06-08 4:19 ` [ 25/82] drm/radeon: fix XFX quirk Ben Hutchings
2012-06-08 4:19 ` [ 26/82] ath9k: fix a use-after-free-bug when ath_tx_setup_buffer() fails Ben Hutchings
2012-06-08 4:19 ` [ 27/82] mac80211: fix ADDBA declined after suspend with wowlan Ben Hutchings
2012-06-08 4:19 ` [ 28/82] mm/fork: fix overflow in vma length when copying mmap on clone Ben Hutchings
2012-06-08 4:19 ` [ 29/82] mm: consider all swapped back pages in used-once logic Ben Hutchings
2012-06-08 4:19 ` [ 30/82] hugetlb: fix resv_map leak in error path Ben Hutchings
2012-06-08 4:19 ` [ 31/82] mm/vmalloc.c: change void* into explict vm_struct* Ben Hutchings
2012-06-08 10:41 ` David Rientjes
2012-06-08 10:55 ` Minchan Kim
2012-06-08 12:16 ` Ben Hutchings
2012-06-08 4:19 ` [ 32/82] mm: fix faulty initialization in vmalloc_init() Ben Hutchings
2012-06-08 4:19 ` [ 33/82] [SCSI] fix scsi_wait_scan Ben Hutchings
2012-06-08 4:19 ` [ 34/82] mm: fix vma_resv_map() NULL pointer Ben Hutchings
2012-06-08 4:19 ` [ 35/82] x86, amd, xen: Avoid NULL pointer paravirt references Ben Hutchings
2012-06-08 4:19 ` [ 36/82] slub: fix a memory leak in get_partial_node() Ben Hutchings
2012-06-08 4:19 ` [ 37/82] ext4: force ro mount if ext4_setup_super() fails Ben Hutchings
2012-06-08 4:19 ` [ 38/82] ext4: disallow hard-linked directory in ext4_lookup Ben Hutchings
2012-06-08 4:19 ` [ 39/82] mtd: nand: fix scan_read_raw_oob Ben Hutchings
2012-06-08 4:19 ` [ 40/82] vfs: increment iversion when a file is truncated Ben Hutchings
2012-06-08 4:19 ` [ 41/82] vfs: umount_tree() might be called on subtree that had never made it Ben Hutchings
2012-06-08 4:19 ` [ 42/82] ext4: add missing save_error_info() to ext4_error() Ben Hutchings
2012-06-08 4:19 ` [ 43/82] ALSA: usb-audio: fix rate_list memory leak Ben Hutchings
2012-06-08 4:19 ` [ 44/82] ext4: add ext4_mb_unload_buddy in the error path Ben Hutchings
2012-06-08 4:19 ` [ 45/82] ext4: remove mb_groups before tearing down the buddy_cache Ben Hutchings
2012-06-08 4:19 ` [ 46/82] drm/radeon: fix bank information in tiling config Ben Hutchings
2012-06-08 4:19 ` [ 47/82] drm/radeon: properly program gart on rv740, juniper, cypress, barts, hemlock Ben Hutchings
2012-06-08 4:19 ` [ 48/82] drm/radeon: fix HD6790, HD6570 backend programming Ben Hutchings
2012-06-08 4:19 ` [ 49/82] drm/ttm: Fix spinlock imbalance Ben Hutchings
2012-06-08 4:19 ` [ 50/82] drm/vmwgfx: Fix nasty write past alloced memory area Ben Hutchings
2012-06-08 4:19 ` [ 51/82] mtd: of_parts: fix breakage in Kconfig Ben Hutchings
2012-06-08 4:19 ` [ 52/82] fec_mpc52xx: fix timestamp filtering Ben Hutchings
2012-06-08 4:19 ` [ 53/82] Bluetooth: btusb: Add vendor specific ID (0a5c 21f3) for BCM20702A0 Ben Hutchings
2012-06-08 4:19 ` [ 54/82] Bluetooth: btusb: add support for BCM20702A0 [0a5c:21e6] Ben Hutchings
2012-06-08 4:19 ` [ 55/82] Bluetooth: btusb: Add USB device ID "0a5c 21e8" Ben Hutchings
2012-06-08 4:19 ` [ 56/82] Bluetooth: btusb: typo in Broadcom SoftSailing id Ben Hutchings
2012-06-08 4:19 ` [ 57/82] Bluetooth: btusb: Add vendor specific ID (0489 e042) for BCM20702A0 Ben Hutchings
2012-06-08 4:19 ` [ 58/82] Bluetooth: Add support for Atheros [13d3:3362] Ben Hutchings
2012-06-08 4:19 ` [ 59/82] Bluetooth: Add support for AR3012 [0cf3:e004] Ben Hutchings
2012-06-08 4:19 ` [ 60/82] Add Foxconn / Hon Hai IDs for btusb module Ben Hutchings
2012-06-08 4:19 ` [ 61/82] Bluetooth: Add support for Foxconn/Hon Hai AR5BBU22 0489:E03C Ben Hutchings
2012-06-08 4:19 ` [ 62/82] drm/i915:: Disable FBC on SandyBridge Ben Hutchings
2012-06-08 4:19 ` [ 63/82] ipv4: Do not use dead fib_info entries Ben Hutchings
2012-06-08 4:19 ` [ 64/82] ipv4: fix the rcu race between free_fib_info and ip_route_output_slow Ben Hutchings
2012-06-08 4:19 ` [ 65/82] set fake_rtables dst to NULL to avoid kernel Oops Ben Hutchings
2012-06-08 4:19 ` [ 66/82] ipv6: fix incorrect ipsec fragment Ben Hutchings
2012-06-08 4:19 ` [ 67/82] l2tp: fix oops in L2TP IP sockets for connect() AF_UNSPEC case Ben Hutchings
2012-06-08 4:19 ` [ 68/82] r8169: missing barriers Ben Hutchings
2012-06-08 4:19 ` [ 69/82] r8169: fix early queue wake-up Ben Hutchings
2012-06-08 4:19 ` [ 70/82] r8169: fix unsigned int wraparound with TSO Ben Hutchings
2012-06-08 4:19 ` [ 71/82] Revert "net: maintain namespace isolation between vlan and real device" Ben Hutchings
2012-06-08 4:19 ` [ 72/82] sctp: check cached dst before using it Ben Hutchings
2012-06-08 4:19 ` [ 73/82] skb: avoid unnecessary reallocations in __skb_cow Ben Hutchings
2012-06-08 4:19 ` [ 74/82] xfrm: take net hdr len into account for esp payload size calculation Ben Hutchings
2012-06-08 4:19 ` [ 75/82] ACPI battery: only refresh the sysfs files when pertinent information changes Ben Hutchings
2012-06-08 4:19 ` Ben Hutchings [this message]
2012-06-08 4:19 ` [ 77/82] iommu/amd: Cache pdev pointer to root-bridge Ben Hutchings
2012-06-08 4:19 ` [ 78/82] drm/radeon/kms: add new Palm, Sumo PCI ids Ben Hutchings
2012-06-08 4:19 ` [ 79/82] drm/radeon/kms: add new BTC " Ben Hutchings
2012-06-08 4:20 ` [ 80/82] btree: fix tree corruption in btree_get_prev() Ben Hutchings
2012-06-08 4:20 ` [ 81/82] kbuild: install kernel-page-flags.h Ben Hutchings
2012-06-08 4:20 ` [ 82/82] asix: allow full size 8021Q frames to be received Ben Hutchings
2012-06-08 5:09 ` [ 00/82] 3.2.20-stable review Ben Hutchings
2012-06-08 13:42 ` Maarten Lankhorst
2012-06-08 14:04 ` Ben Hutchings
2012-06-08 22:54 ` Ben Hutchings
2012-06-10 16:54 ` Maarten Lankhorst
2012-06-17 14:04 ` Ben Hutchings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120608041851.096743193@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).