From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
kernel-team@lists.ubuntu.com
Cc: Ilya Dryomov <idryomov@redhat.com>, Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 3.13.y-ckt 51/80] rbd: fix rbd_dev_parent_get() when parent_overlap == 0
Date: Thu, 19 Mar 2015 15:35:39 -0700 [thread overview]
Message-ID: <1426804568-2907-52-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1426804568-2907-1-git-send-email-kamal@canonical.com>
3.13.11-ckt17 -stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <idryomov@redhat.com>
commit ae43e9d05eb4bd324155292f889fbd001c4faea8 upstream.
The comment for rbd_dev_parent_get() said
* We must get the reference before checking for the overlap to
* coordinate properly with zeroing the parent overlap in
* rbd_dev_v2_parent_info() when an image gets flattened. We
* drop it again if there is no overlap.
but the "drop it again if there is no overlap" part was missing from
the implementation. This lead to absurd parent_ref values for images
with parent_overlap == 0, as parent_ref was incremented for each
img_request and virtually never decremented.
Fix this by leveraging the fact that refresh path calls
rbd_dev_v2_parent_info() under header_rwsem and use it for read in
rbd_dev_parent_get(), instead of messing around with atomics. Get rid
of barriers in rbd_dev_v2_parent_info() while at it - I don't see what
they'd pair with now and I suspect we are in a pretty miserable
situation as far as proper locking goes regardless.
Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
Reviewed-by: Josh Durgin <jdurgin@redhat.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
drivers/block/rbd.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 5224f46..caa97de 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1945,32 +1945,26 @@ static void rbd_dev_parent_put(struct rbd_device *rbd_dev)
* If an image has a non-zero parent overlap, get a reference to its
* parent.
*
- * We must get the reference before checking for the overlap to
- * coordinate properly with zeroing the parent overlap in
- * rbd_dev_v2_parent_info() when an image gets flattened. We
- * drop it again if there is no overlap.
- *
* Returns true if the rbd device has a parent with a non-zero
* overlap and a reference for it was successfully taken, or
* false otherwise.
*/
static bool rbd_dev_parent_get(struct rbd_device *rbd_dev)
{
- int counter;
+ int counter = 0;
if (!rbd_dev->parent_spec)
return false;
- counter = atomic_inc_return_safe(&rbd_dev->parent_ref);
- if (counter > 0 && rbd_dev->parent_overlap)
- return true;
-
- /* Image was flattened, but parent is not yet torn down */
+ down_read(&rbd_dev->header_rwsem);
+ if (rbd_dev->parent_overlap)
+ counter = atomic_inc_return_safe(&rbd_dev->parent_ref);
+ up_read(&rbd_dev->header_rwsem);
if (counter < 0)
rbd_warn(rbd_dev, "parent reference overflow\n");
- return false;
+ return counter > 0;
}
/*
@@ -3894,7 +3888,6 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
*/
if (rbd_dev->parent_overlap) {
rbd_dev->parent_overlap = 0;
- smp_mb();
rbd_dev_parent_put(rbd_dev);
pr_info("%s: clone image has been flattened\n",
rbd_dev->disk->disk_name);
@@ -3938,7 +3931,6 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
* treat it specially.
*/
rbd_dev->parent_overlap = overlap;
- smp_mb();
if (!overlap) {
/* A null parent_spec indicates it's the initial probe */
--
1.9.1
next prev parent reply other threads:[~2015-03-19 22:46 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 22:34 [3.13.y-ckt stable] Linux 3.13.11-ckt17 stable review Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 01/80] splice: Apply generic position and size checks to each write Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 02/80] clocksource: arch_timer: Only use the virtual counter (CNTVCT) on arm64 Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 03/80] openvswitch: Silence RCU lockdep checks from flow lookup Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 04/80] openvswitch: Use exact lookup for flow_get and flow_del Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 05/80] Bluetooth: Enable Atheros 0cf3:311e for firmware upload Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 06/80] Bluetooth: Add firmware update for Atheros 0cf3:311f Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 07/80] Bluetooth: btusb: Add IMC Networks (Broadcom based) Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 08/80] Bluetooth: sort the list of IDs in the source code Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 09/80] Bluetooth: append new supported device to the list [0b05:17d0] Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 10/80] Bluetooth: Add support for Intel bootloader devices Kamal Mostafa
2015-03-19 22:34 ` [PATCH 3.13.y-ckt 11/80] Bluetooth: Ignore isochronous endpoints for Intel USB bootloader Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 12/80] Bluetooth: Add support for Acer [13D3:3432] Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 13/80] Bluetooth: Add support for Broadcom device of Asus Z97-DELUXE motherboard Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 14/80] Add a new PID/VID 0227/0930 for AR3012 Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 15/80] Bluetooth: Add support for Acer [0489:e078] Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 16/80] Bluetooth: Add USB device 04ca:3010 as Atheros AR3012 Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 17/80] x86: mm: move mmap_sem unlock from mm_fault_error() to caller Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 18/80] vm: add VM_FAULT_SIGSEGV handling support Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 19/80] vm: make stack guard page errors return VM_FAULT_SIGSEGV rather than SIGBUS Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 20/80] net: sctp: fix slab corruption from use after free on INIT collisions Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 21/80] ipv4: try to cache dst_entries which would cause a redirect Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 22/80] x86, mm/ASLR: Fix stack randomization on 64-bit systems Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 23/80] net: llc: use correct size for sysctl timeout entries Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 24/80] net: rds: use correct size for max unacked packets and bytes Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 25/80] spi/pxa2xx: Clear cur_chip pointer before starting next message Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 26/80] spi: dw: Fix detecting FIFO depth Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 27/80] spi: dw-mid: fix FIFO size Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 28/80] ASoC: wm8960: Fix capture sample rate from 11250 to 11025 Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 29/80] regulator: core: fix race condition in regulator_put() Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 30/80] ASoC: omap-mcbsp: Correct CBM_CFS dai format configuration Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 31/80] powerpc/xmon: Fix another endiannes issue in RTAS call from xmon Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 32/80] can: c_can: end pending transmission on network stop (ifdown) Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 33/80] nfs: fix dio deadlock when O_DIRECT flag is flipped Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 34/80] NFSv4.1: Fix an Oops in nfs41_walk_client_list Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 35/80] Input: i8042 - add noloop quirk for Medion Akoya E7225 (MD98857) Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 36/80] mac80211: properly set CCK flag in radiotap Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 37/80] nl80211: fix per-station group key get/del and memory leak Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 38/80] i2c: s3c2410: fix ABBA deadlock by keeping clock prepared Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 39/80] usb-storage/SCSI: blacklist FUA on JMicron 152d:2566 USB-SATA controller Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 40/80] drm/i915: Only fence tiled region of object Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 41/80] drm/i915: Fix and clean BDW PCH identification Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 42/80] drm/i915: BDW Fix Halo PCI IDs marked as ULT Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 43/80] ALSA: seq-dummy: remove deadlock-causing events on close Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 44/80] drivers/rtc/rtc-s5m.c: terminate s5m_rtc_id array with empty element Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 45/80] drivers: net: cpsw: discard dual emac default vlan configuration Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 46/80] can: kvaser_usb: Do not sleep in atomic context Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 47/80] can: kvaser_usb: Send correct context to URB completion Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 48/80] can: kvaser_usb: Retry the first bulk transfer on -ETIMEDOUT Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 49/80] can: kvaser_usb: Fix state handling upon BUS_ERROR events Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 50/80] quota: Switch ->get_dqblk() and ->set_dqblk() to use bytes as space units Kamal Mostafa
2015-03-19 22:35 ` Kamal Mostafa [this message]
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 52/80] rbd: drop parent_ref in rbd_dev_unprobe() unconditionally Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 53/80] dm cache: fix missing ERR_PTR returns and handling Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 54/80] dm thin: don't allow messages to be sent to a pool target in READ_ONLY or FAIL mode Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 55/80] net: cls_bpf: fix size mismatch on filter preparation Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 56/80] net: cls_bpf: fix auto generation of per list handles Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 57/80] ipv6: replacing a rt6_info needs to purge possible propagated rt6_infos too Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 58/80] perf: Tighten (and fix) the grouping condition Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 59/80] arc: mm: Fix build failure Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 60/80] MIPS: IRQ: Fix disable_irq on CPU IRQs Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 61/80] Complete oplock break jobs before closing file handle Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 62/80] smpboot: Add missing get_online_cpus() in smpboot_register_percpu_thread() Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 63/80] ASoC: atmel_ssc_dai: fix start event for I2S mode Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 64/80] spi: fsl-dspi: Fix memory leak Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 65/80] spi: spi-fsl-dspi: Remove usage of devm_kzalloc Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 66/80] ALSA: ak411x: Fix stall in work callback Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 67/80] lib/checksum.c: fix carry in csum_tcpudp_nofold Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 68/80] MIPS: Fix kernel lockup or crash after CPU offline/online Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 69/80] gpio: sysfs: fix memory leak in gpiod_export_link Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 70/80] gpio: sysfs: fix memory leak in gpiod_sysfs_set_active_low Kamal Mostafa
2015-03-19 22:35 ` [PATCH 3.13.y-ckt 71/80] MIPS: Fix C0_Pagegrain[IEC] support Kamal Mostafa
2015-03-19 23:10 ` David Daney
2015-03-20 17:02 ` Kamal Mostafa
2015-03-19 22:36 ` [PATCH 3.13.y-ckt 72/80] PCI: Add NEC variants to Stratus ftServer PCIe DMI check Kamal Mostafa
2015-03-19 22:36 ` [PATCH 3.13.y-ckt 73/80] ASoC: sgtl5000: add delay before first I2C access Kamal Mostafa
2015-03-19 22:36 ` [PATCH 3.13.y-ckt 74/80] PCI: Handle read-only BARs on AMD CS553x devices Kamal Mostafa
2015-03-19 22:36 ` [PATCH 3.13.y-ckt 75/80] mm: pagewalk: call pte_hole() for VM_PFNMAP during walk_page_range Kamal Mostafa
2015-03-19 22:36 ` [PATCH 3.13.y-ckt 76/80] nilfs2: fix deadlock of segment constructor over I_SYNC flag Kamal Mostafa
2015-03-19 22:36 ` [PATCH 3.13.y-ckt 77/80] tcp: ipv4: initialize unicast_sock sk_pacing_rate Kamal Mostafa
2015-03-19 22:36 ` [PATCH 3.13.y-ckt 78/80] caif: remove wrong dev_net_set() call Kamal Mostafa
2015-03-19 22:36 ` [PATCH 3.13.y-ckt 79/80] qlge: Fix qlge_update_hw_vlan_features to handle if interface is down Kamal Mostafa
2015-03-19 22:36 ` [PATCH 3.13.y-ckt 80/80] ip6_gre: fix endianness errors in ip6gre_err Kamal Mostafa
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=1426804568-2907-52-git-send-email-kamal@canonical.com \
--to=kamal@canonical.com \
--cc=idryomov@redhat.com \
--cc=kernel-team@lists.ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
--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®