mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org, "Neil Brown" <neilb@suse.de>,
	"Kent Overstreet" <koverstreet@google.com>,
	"Boaz Harrosh" <bharrosh@panasas.com>,
	"Jens Axboe" <axboe@kernel.dk>
Subject: [082/121] block: Add bio_for_each_segment_all()
Date: Sun, 08 Sep 2013 03:52:01 +0100	[thread overview]
Message-ID: <lsq.1378608721.102338601@decadent.org.uk> (raw)
In-Reply-To: <lsq.1378608720.401499712@decadent.org.uk>

3.2.51-rc1 review patch.  If anyone has any objections, please let me know.

------------------

From: Kent Overstreet <koverstreet@google.com>

commit d74c6d514fe314b8bdab58b487b25992291577ec upstream.

__bio_for_each_segment() iterates bvecs from the specified index
instead of bio->bv_idx.  Currently, the only usage is to walk all the
bvecs after the bio has been advanced by specifying 0 index.

For immutable bvecs, we need to split these apart;
bio_for_each_segment() is going to have a different implementation.
This will also help document the intent of code that's using it -
bio_for_each_segment_all() is only legal to use for code that owns the
bio.

Signed-off-by: Kent Overstreet <koverstreet@google.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: Neil Brown <neilb@suse.de>
CC: Boaz Harrosh <bharrosh@panasas.com>
[bwh: Backported to 3.2: drop inapplicable change to drivers/block/rbd.c.
 This is a prerequisite for commit 35dc248383bb 'sg: Fix user memory
 corruption when SG_IO is interrupted by a signal']
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1139,7 +1139,7 @@ read_again:
 			 * know the original bi_idx, so we just free
 			 * them all
 			 */
-			__bio_for_each_segment(bvec, mbio, j, 0)
+			bio_for_each_segment_all(bvec, mbio, j)
 				bvec->bv_page = r1_bio->behind_bvecs[j].bv_page;
 			if (test_bit(WriteMostly, &conf->mirrors[i].rdev->flags))
 				atomic_inc(&r1_bio->behind_remaining);
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -734,7 +734,7 @@ static int __bio_copy_iov(struct bio *bi
 	int iov_idx = 0;
 	unsigned int iov_off = 0;
 
-	__bio_for_each_segment(bvec, bio, i, 0) {
+	bio_for_each_segment_all(bvec, bio, i) {
 		char *bv_addr = page_address(bvec->bv_page);
 		unsigned int bv_len = iovecs[i].bv_len;
 
@@ -916,7 +916,7 @@ struct bio *bio_copy_user_iov(struct req
 	return bio;
 cleanup:
 	if (!map_data)
-		bio_for_each_segment(bvec, bio, i)
+		bio_for_each_segment_all(bvec, bio, i)
 			__free_page(bvec->bv_page);
 
 	bio_put(bio);
@@ -1130,7 +1130,7 @@ static void __bio_unmap_user(struct bio
 	/*
 	 * make sure we dirty pages we wrote to
 	 */
-	__bio_for_each_segment(bvec, bio, i, 0) {
+	bio_for_each_segment_all(bvec, bio, i) {
 		if (bio_data_dir(bio) == READ)
 			set_page_dirty_lock(bvec->bv_page);
 
@@ -1236,7 +1236,7 @@ static void bio_copy_kern_endio(struct b
 	int i;
 	char *p = bmd->sgvecs[0].iov_base;
 
-	__bio_for_each_segment(bvec, bio, i, 0) {
+	bio_for_each_segment_all(bvec, bio, i) {
 		char *addr = page_address(bvec->bv_page);
 		int len = bmd->iovecs[i].bv_len;
 
@@ -1276,7 +1276,7 @@ struct bio *bio_copy_kern(struct request
 	if (!reading) {
 		void *p = data;
 
-		bio_for_each_segment(bvec, bio, i) {
+		bio_for_each_segment_all(bvec, bio, i) {
 			char *addr = page_address(bvec->bv_page);
 
 			memcpy(addr, p, bvec->bv_len);
@@ -1556,7 +1556,7 @@ sector_t bio_sector_offset(struct bio *b
 	if (index >= bio->bi_idx)
 		index = bio->bi_vcnt - 1;
 
-	__bio_for_each_segment(bv, bio, i, 0) {
+	bio_for_each_segment_all(bv, bio, i) {
 		if (i == index) {
 			if (offset > bv->bv_offset)
 				sectors += (offset - bv->bv_offset) / sector_sz;
--- a/fs/exofs/ore.c
+++ b/fs/exofs/ore.c
@@ -401,7 +401,7 @@ static void _clear_bio(struct bio *bio)
 	struct bio_vec *bv;
 	unsigned i;
 
-	__bio_for_each_segment(bv, bio, i, 0) {
+	bio_for_each_segment_all(bv, bio, i) {
 		unsigned this_count = bv->bv_len;
 
 		if (likely(PAGE_SIZE == this_count))
--- a/fs/exofs/ore_raid.c
+++ b/fs/exofs/ore_raid.c
@@ -432,7 +432,7 @@ static void _mark_read4write_pages_uptod
 		if (!bio)
 			continue;
 
-		__bio_for_each_segment(bv, bio, i, 0) {
+		bio_for_each_segment_all(bv, bio, i) {
 			struct page *page = bv->bv_page;
 
 			SetPageUptodate(page);
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -135,16 +135,27 @@ static inline int bio_has_allocated_vec(
 #define bio_io_error(bio) bio_endio((bio), -EIO)
 
 /*
- * drivers should not use the __ version unless they _really_ want to
- * run through the entire bio and not just pending pieces
+ * drivers should not use the __ version unless they _really_ know what
+ * they're doing
  */
 #define __bio_for_each_segment(bvl, bio, i, start_idx)			\
 	for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx);	\
 	     i < (bio)->bi_vcnt;					\
 	     bvl++, i++)
 
+/*
+ * drivers should _never_ use the all version - the bio may have been split
+ * before it got to the driver and the driver won't own all of it
+ */
+#define bio_for_each_segment_all(bvl, bio, i)				\
+	for (i = 0;							\
+	     bvl = bio_iovec_idx((bio), (i)), i < (bio)->bi_vcnt;	\
+	     i++)
+
 #define bio_for_each_segment(bvl, bio, i)				\
-	__bio_for_each_segment(bvl, bio, i, (bio)->bi_idx)
+	for (i = (bio)->bi_idx;						\
+	     bvl = bio_iovec_idx((bio), (i)), i < (bio)->bi_vcnt;	\
+	     i++)
 
 /*
  * get a reference to a bio, so it won't disappear. the intended use is
--- a/mm/bounce.c
+++ b/mm/bounce.c
@@ -132,7 +132,7 @@ static void bounce_end_io(struct bio *bi
 	/*
 	 * free up bounce indirect pages used
 	 */
-	__bio_for_each_segment(bvec, bio, i, 0) {
+	bio_for_each_segment_all(bvec, bio, i) {
 		org_vec = bio_orig->bi_io_vec + i;
 		if (bvec->bv_page == org_vec->bv_page)
 			continue;


  parent reply	other threads:[~2013-09-08  3:42 UTC|newest]

Thread overview: 134+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-08  2:52 [000/121] 3.2.51-rc1 review Ben Hutchings
2013-09-08  2:52 ` [088/121] nilfs2: fix issue with counting number of bio requests for BIO_EOPNOTSUPP error detection Ben Hutchings
2013-09-08  2:52 ` [063/121] zd1201: do not use stack as URB transfer_buffer Ben Hutchings
2013-09-08  2:52 ` [029/121] ath9k_htc: do some initial hardware configuration Ben Hutchings
2013-09-08  2:52 ` [027/121] iwlwifi: dvm: don't send BT_CONFIG on devices w/o Bluetooth Ben Hutchings
2013-09-08  2:52 ` [113/121] m32r: add memcpy() for CONFIG_KERNEL_GZIP=y Ben Hutchings
2013-09-08  2:52 ` [040/121] serial/mxs-auart: fix race condition in interrupt handler Ben Hutchings
2013-09-08  2:52 ` [032/121] Bluetooth: ath3k: Add support for Fujitsu Lifebook UH5x2 [04c5:1330] Ben Hutchings
2013-09-08  2:52 ` [011/121] ipv6: take rtnl_lock and mark mrt6 table as freed on namespace cleanup Ben Hutchings
2013-09-08  2:52 ` [046/121] virtio: console: fix raising SIGIO after port unplug Ben Hutchings
2013-09-08  2:52 ` [089/121] Revert "PM / Domains: Fix handling of wakeup devices during system resume" Ben Hutchings
2013-09-08  2:52 ` [121/121] x86/xen: do not identity map UNUSABLE regions in the machine E820 Ben Hutchings
2013-09-08  2:52 ` [053/121] iwlwifi: dvm: fix calling ieee80211_chswitch_done() with NULL Ben Hutchings
2013-09-08  2:52 ` [016/121] drm/i915/lvds: ditch ->prepare special case Ben Hutchings
2013-09-08  2:52 ` [067/121] jbd2: Fix use after free after error in jbd2_journal_dirty_metadata() Ben Hutchings
2013-09-08  2:52 ` [076/121] USB: mos7720: fix broken control requests Ben Hutchings
2013-09-08  2:52 ` [058/121] ALSA: 6fire: fix DMA issues with URB transfer_buffer usage Ben Hutchings
2013-09-08  2:52 ` [009/121] sysctl net: Keep tcp_syn_retries inside the boundary Ben Hutchings
2013-09-08  2:52 ` [075/121] usb: add two quirky touchscreen Ben Hutchings
2013-09-08  2:52 ` [106/121] drivers/base/memory.c: fix show_mem_removable() to handle missing sections Ben Hutchings
2013-09-08  2:52 ` [004/121] sched: Fix the broken sched_rr_get_interval() Ben Hutchings
2013-09-08  2:52 ` [033/121] Bluetooth: ath3k: Add support for ID 0x13d3/0x3402 Ben Hutchings
2013-09-08  2:52 ` [101/121] powerpc: Don't Oops when accessing /proc/powerpc/lparcfg without hypervisor Ben Hutchings
2013-09-08  2:52 ` [049/121] USB: serial: ftdi_sio: add more RT Systems ftdi devices Ben Hutchings
2013-09-08  2:52 ` [084/121] of: fdt: fix memory initialization for expanded DT Ben Hutchings
2013-09-08  2:52 ` [002/121] mm/memory-hotplug: fix lowmem count overflow when offline pages Ben Hutchings
2013-09-08  2:52 ` [093/121] sound: Fix make allmodconfig on MIPS correctly Ben Hutchings
2013-09-08  2:52 ` [055/121] iwl4965: reset firmware after rfkill off Ben Hutchings
2013-09-08  2:52 ` [119/121] target: Fix trailing ASCII space usage in INQUIRY vendor+model Ben Hutchings
2013-09-08  2:52 ` [114/121] m32r: make memset() global for CONFIG_KERNEL_BZIP2=y Ben Hutchings
2013-09-08  2:52 ` [003/121] libata: make it clear that sata_inic162x is experimental Ben Hutchings
2013-09-08  2:52 ` [081/121] xen/events: mask events when changing their VCPU binding Ben Hutchings
2013-09-08  2:52 ` [077/121] USB: keyspan: fix null-deref at disconnect and release Ben Hutchings
2013-09-08  2:52 ` [109/121] drm/vmwgfx: Split GMR2_REMAP commands if they are to large Ben Hutchings
2013-09-08  2:52 ` [100/121] ath9k_htc: Restore skb headroom when returning skb to mac80211 Ben Hutchings
2013-09-08  2:52 ` [086/121] [SCSI] zfcp: fix schedule-inside-lock in scsi_device list loops Ben Hutchings
2013-09-08  2:52 ` [023/121] jfs: fix readdir cookie incompatibility with NFSv4 Ben Hutchings
2013-09-08  2:52 ` [118/121] ALSA: opti9xx: Fix conflicting driver object name Ben Hutchings
2013-09-08  2:52 ` [030/121] Bluetooth: Add support for Foxconn/Hon Hai [0489:e04d] Ben Hutchings
2013-09-08  2:52 ` [105/121] SUNRPC: Fix memory corruption issue on 32-bit highmem systems Ben Hutchings
2013-09-08  2:52 ` [006/121] perf: Fix event group context move Ben Hutchings
2013-09-08  2:52 ` [104/121] sunrpc: remove the second argument of k[un]map_atomic() Ben Hutchings
2013-09-08  2:52 ` [066/121] ALSA: 6fire: make buffers DMA-able (midi) Ben Hutchings
2013-09-08  2:52 ` [048/121] rt2x00: fix stop queue Ben Hutchings
2013-09-08  2:52 ` [074/121] m68k: Truncate base in do_div() Ben Hutchings
2013-09-08  2:52 ` [010/121] sctp: fully initialize sctp_outq in sctp_outq_init Ben Hutchings
2013-09-08  2:52 ` [028/121] iwlwifi: add DELL SKU for 5150 HMC Ben Hutchings
2013-09-08  2:52 ` [108/121] drm/i915: ivb: fix edp voltage swing reg val Ben Hutchings
2013-09-08  2:52 ` [018/121] ALSA: usb-audio: skip UAC2 EFFECT_UNIT Ben Hutchings
2013-09-08  2:52 ` [035/121] Bluetooth: Add support for Atheros [0cf3:e003] Ben Hutchings
2013-09-08  2:52 ` [095/121] alpha: makefile: don't enforce small data model for kernel builds Ben Hutchings
2013-09-08  2:52 ` [047/121] virtio: console: return -ENODEV on all read operations after unplug Ben Hutchings
2013-09-08  2:52 ` [061/121] hwmon: (adt7470) Fix incorrect return code check Ben Hutchings
2013-09-08  2:52 ` [073/121] m68k/atari: ARAnyM - Fix NatFeat module support Ben Hutchings
2013-09-08  2:52 ` [022/121] NFSv4.1: integer overflow in decode_cb_sequence_args() Ben Hutchings
2013-09-08  2:52 ` [083/121] [SCSI] sg: Fix user memory corruption when SG_IO is interrupted by a signal Ben Hutchings
2013-09-08  2:52 ` [092/121] sound: Fix make allmodconfig on MIPS Ben Hutchings
2013-09-08  2:52 ` [094/121] CRIS: Add _sdata to vmlinux.lds.S Ben Hutchings
2013-09-08  2:52 ` [072/121] fs/proc/task_mmu.c: fix buffer overflow in add_page_map() Ben Hutchings
2013-09-08  2:52 ` [031/121] Bluetooth: Add support for Mediatek Bluetooth device [0e8d:763f] Ben Hutchings
2013-09-08  2:52 ` [026/121] mac80211: fix duplicate retransmission detection Ben Hutchings
2013-09-08  2:52 ` [014/121] af_key: more info leaks in pfkey messages Ben Hutchings
2013-09-08  2:52 ` [043/121] virtio: console: fix race with port unplug and open/close Ben Hutchings
2013-09-08  2:52 ` [057/121] tracing: Fix fields of struct trace_iterator that are zeroed by mistake Ben Hutchings
2013-09-08  2:52 ` [098/121] Hexagon: misc compile warning/error cleanup due to missing headers Ben Hutchings
2013-09-08  2:52 ` [005/121] drm/i915: quirk no PCH_PWM_ENABLE for Dell XPS13 backlight Ben Hutchings
2013-09-08  2:52 ` [062/121] ext4: fix mount/remount error messages for incompatible mount options Ben Hutchings
2013-09-08  2:52 ` [069/121] USB: ti_usb_3410_5052: fix big-endian firmware handling Ben Hutchings
2013-09-08  2:52 ` [107/121] workqueue: cond_resched() after processing each work item Ben Hutchings
2013-09-08  2:52 ` [103/121] powerpc/hvsi: Increase handshake timeout from 200ms to 400ms Ben Hutchings
2013-09-08  2:52 ` [037/121] x86, fpu: correct the asm constraints for fxsave, unbreak mxcsr.daz Ben Hutchings
2013-09-08  2:52 ` [012/121] usbnet: do not pretend to support SG/TSO Ben Hutchings
2013-09-08  2:52 ` [025/121] nl80211: fix mgmt tx status and testmode reporting for netns Ben Hutchings
2013-09-08  2:52 ` [013/121] net_sched: Fix stack info leak in cbq_dump_wrr() Ben Hutchings
2013-09-08  2:52 ` [099/121] iwl4965: fix rfkill set state regression Ben Hutchings
2013-09-08  2:52 ` [052/121] cifs: extend the buffer length enought for sprintf() using Ben Hutchings
2013-09-09  3:03   ` Scott Lovenberg
2013-09-08  2:52 ` [008/121] arcnet: cleanup sizeof parameter Ben Hutchings
2013-09-08  2:52 ` [110/121] x86 get_unmapped_area: Access mmap_legacy_base through mm_struct member Ben Hutchings
2013-09-08  2:52 ` [051/121] drm/radeon/atom: initialize more atom interpretor elements to 0 Ben Hutchings
2013-09-08  2:52 ` [090/121] SCSI: nsp32: use mdelay instead of large udelay constants Ben Hutchings
2013-09-08  2:52 ` [115/121] microblaze: Fix __futex_atomic_op macro register usage Ben Hutchings
2013-09-08  2:52 ` [001/121] ifb: Include <linux/sched.h> Ben Hutchings
2013-09-08  2:52 ` [054/121] iwl4965: set power mode early Ben Hutchings
2013-09-08  2:52 ` [034/121] Bluetooth: Add support for Atheros [0cf3:3121] Ben Hutchings
2013-09-08  2:52 ` [021/121] slab: introduce kmalloc_array() Ben Hutchings
2013-09-08  2:52 ` [097/121] sparc32: support atomic64_t Ben Hutchings
2013-09-08  2:52 ` [065/121] ALSA: 6fire: make buffers DMA-able (pcm) Ben Hutchings
2013-09-08  2:52 ` [017/121] af_key: initialize satype in key_notify_policy_flush() Ben Hutchings
2013-09-08  2:52 ` [070/121] ARM: 7809/1: perf: fix event validation for software group leaders Ben Hutchings
2013-09-08  2:52 ` [050/121] ACPI / battery: Fix parsing _BIX return value Ben Hutchings
2013-09-08  2:52 ` Ben Hutchings [this message]
2013-09-08  2:52 ` [102/121] powerpc: Work around gcc miscompilation of __pa() on 64-bit Ben Hutchings
2013-09-08  2:52 ` [045/121] virtio: console: clean up port data immediately at time of unplug Ben Hutchings
2013-09-08  2:52 ` [060/121] drm/radeon: always program the MC on startup Ben Hutchings
2013-09-08  2:52 ` [019/121] ALSA: usb: Parse UAC2 extension unit like for UAC1 Ben Hutchings
2013-09-08  2:52 ` [117/121] sparc32: Add ucmpdi2.o to obj-y instead of lib-y Ben Hutchings
2013-09-08  2:52 ` [111/121] pci: frv architecture needs generic setup-bus infrastructure Ben Hutchings
2013-09-08  2:52 ` [059/121] cifs: don't instantiate new dentries in readdir for inodes that need to be revalidated immediately Ben Hutchings
2013-09-08  2:52 ` [024/121] vm: add no-mmu vm_iomap_memory() stub Ben Hutchings
2013-09-08  2:52 ` [044/121] virtio: console: fix race in port_fops_open() and port unplug Ben Hutchings
2013-09-08  2:52 ` [091/121] microblaze: Update microblaze defconfigs Ben Hutchings
2013-09-08  2:52 ` [041/121] serial/mxs-auart: increase time to wait for transmitter to become idle Ben Hutchings
2013-09-08  2:52 ` [015/121] net_sched: info leak in atm_tc_dump_class() Ben Hutchings
2013-09-08  2:52 ` [020/121] ALSA: ak4xx-adda: info leak in ak4xxx_capture_source_info() Ben Hutchings
2013-09-08  2:52 ` [096/121] [PARISC] include <linux/prefetch.h> in drivers/parisc/iommu-helpers.h Ben Hutchings
2013-09-08  2:52 ` [068/121] USB: adutux: fix big-endian device-type reporting Ben Hutchings
2013-09-08  2:52 ` [038/121] mwifiex: Add missing endian conversion Ben Hutchings
2013-09-08  2:52 ` [080/121] xen/events: initialize local per-cpu mask for all possible events Ben Hutchings
2013-09-08  2:52 ` [036/121] ARM: 7791/1: a.out: remove partial a.out support Ben Hutchings
2013-09-08  2:52 ` [120/121] KVM: s390: move kvm_guest_enter,exit closer to sie Ben Hutchings
2013-09-08  2:52 ` [064/121] Hostap: copying wrong data prism2_ioctl_giwaplist() Ben Hutchings
2013-09-08  2:52 ` [112/121] m32r: consistently use "suffix-$(...)" Ben Hutchings
2013-09-10  3:59   ` Hirokazu Takata
2013-09-08  2:52 ` [071/121] perf/arm: Fix armpmu_map_hw_event() Ben Hutchings
2013-09-08  2:52 ` [078/121] drm/i915: Invalidate TLBs for the rings after a reset Ben Hutchings
2013-09-08  2:52 ` [085/121] [SCSI] zfcp: fix lock imbalance by reworking request queue locking Ben Hutchings
2013-09-08  2:52 ` [079/121] libata: apply behavioral quirks to sil3826 PMP Ben Hutchings
2013-09-08  2:52 ` [007/121] perf tools: Add anonymous huge page recognition Ben Hutchings
2013-09-08  2:52 ` [039/121] USB: mos7840: fix race in register handling Ben Hutchings
2013-09-08  2:52 ` [056/121] [SCSI] megaraid_sas: megaraid_sas driver init fails in kdump kernel Ben Hutchings
2013-09-08  2:52 ` [116/121] sparc32: add ucmpdi2 Ben Hutchings
2013-09-08  2:52 ` [087/121] nilfs2: remove double bio_put() in nilfs_end_bio_write() for BIO_EOPNOTSUPP error Ben Hutchings
2013-09-08  2:52 ` [042/121] ixgbe: Fix Tx Hang issue with lldpad on 82598EB Ben Hutchings
2013-09-08  3:53 ` [000/121] 3.2.51-rc1 review Ben Hutchings
2013-09-08  7:10 ` Guenter Roeck
2013-09-08  8:18   ` Geert Uytterhoeven
2013-09-08 16:52     ` Guenter Roeck
2013-10-20 11:56       ` Ben Hutchings
2013-10-20 16:23         ` Guenter Roeck
2013-10-20 18:05           ` Ben Hutchings
2013-10-20 19:28             ` Guenter Roeck
2013-09-09 13:16     ` Greg Ungerer
2013-09-09 13:26       ` Guenter Roeck

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=lsq.1378608721.102338601@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=bharrosh@panasas.com \
    --cc=koverstreet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=stable@vger.kernel.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

all inboxes | Powered by JetHome®