All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Mikulas Patocka <mpatocka@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>
Subject: [PATCH 4.4 015/103] dm bufio: make the parameter "retain_bytes" unsigned long
Date: Tue, 23 May 2017 22:08:41 +0200	[thread overview]
Message-ID: <20170523200858.673632398@linuxfoundation.org> (raw)
In-Reply-To: <20170523200856.903752266@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

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

From: Mikulas Patocka <mpatocka@redhat.com>

commit 13840d38016203f0095cd547b90352812d24b787 upstream.

Change the type of the parameter "retain_bytes" from unsigned to
unsigned long, so that on 64-bit machines the user can set more than
4GiB of data to be retained.

Also, change the type of the variable "count" in the function
"__evict_old_buffers" to unsigned long.  The assignment
"count = c->n_buffers[LIST_CLEAN] + c->n_buffers[LIST_DIRTY];"
could result in unsigned long to unsigned overflow and that could result
in buffers not being freed when they should.

While at it, avoid division in get_retain_buffers().  Division is slow,
we can change it to shift because we have precalculated the log2 of
block size.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-bufio.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -222,7 +222,7 @@ static DEFINE_SPINLOCK(param_spinlock);
  * Buffers are freed after this timeout
  */
 static unsigned dm_bufio_max_age = DM_BUFIO_DEFAULT_AGE_SECS;
-static unsigned dm_bufio_retain_bytes = DM_BUFIO_DEFAULT_RETAIN_BYTES;
+static unsigned long dm_bufio_retain_bytes = DM_BUFIO_DEFAULT_RETAIN_BYTES;
 
 static unsigned long dm_bufio_peak_allocated;
 static unsigned long dm_bufio_allocated_kmem_cache;
@@ -1514,10 +1514,10 @@ static bool __try_evict_buffer(struct dm
 	return true;
 }
 
-static unsigned get_retain_buffers(struct dm_bufio_client *c)
+static unsigned long get_retain_buffers(struct dm_bufio_client *c)
 {
-        unsigned retain_bytes = ACCESS_ONCE(dm_bufio_retain_bytes);
-        return retain_bytes / c->block_size;
+        unsigned long retain_bytes = ACCESS_ONCE(dm_bufio_retain_bytes);
+        return retain_bytes >> (c->sectors_per_block_bits + SECTOR_SHIFT);
 }
 
 static unsigned long __scan(struct dm_bufio_client *c, unsigned long nr_to_scan,
@@ -1527,7 +1527,7 @@ static unsigned long __scan(struct dm_bu
 	struct dm_buffer *b, *tmp;
 	unsigned long freed = 0;
 	unsigned long count = nr_to_scan;
-	unsigned retain_target = get_retain_buffers(c);
+	unsigned long retain_target = get_retain_buffers(c);
 
 	for (l = 0; l < LIST_SIZE; l++) {
 		list_for_each_entry_safe_reverse(b, tmp, &c->lru[l], lru_list) {
@@ -1753,8 +1753,8 @@ static bool older_than(struct dm_buffer
 static void __evict_old_buffers(struct dm_bufio_client *c, unsigned long age_hz)
 {
 	struct dm_buffer *b, *tmp;
-	unsigned retain_target = get_retain_buffers(c);
-	unsigned count;
+	unsigned long retain_target = get_retain_buffers(c);
+	unsigned long count;
 	LIST_HEAD(write_list);
 
 	dm_bufio_lock(c);
@@ -1915,7 +1915,7 @@ MODULE_PARM_DESC(max_cache_size_bytes, "
 module_param_named(max_age_seconds, dm_bufio_max_age, uint, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(max_age_seconds, "Max age of a buffer in seconds");
 
-module_param_named(retain_bytes, dm_bufio_retain_bytes, uint, S_IRUGO | S_IWUSR);
+module_param_named(retain_bytes, dm_bufio_retain_bytes, ulong, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(retain_bytes, "Try to keep at least this many bytes cached in memory");
 
 module_param_named(peak_allocated_bytes, dm_bufio_peak_allocated, ulong, S_IRUGO | S_IWUSR);

  parent reply	other threads:[~2017-05-23 20:35 UTC|newest]

Thread overview: 121+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-23 20:08 [PATCH 4.4 000/103] 4.4.70-stable review Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 001/103] usb: misc: legousbtower: Fix buffers on stack Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 002/103] usb: misc: legousbtower: Fix memory leak Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 003/103] USB: ene_usb6250: fix DMA to the stack Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 004/103] watchdog: pcwd_usb: fix NULL-deref at probe Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 005/103] char: lp: fix possible integer overflow in lp_setup() Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 006/103] USB: core: replace %p with %pK Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 007/103] ARM: tegra: paz00: Mark panel regulator as enabled on boot Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 008/103] tpm_crb: check for bad response size Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 009/103] infiniband: call ipv6 route lookup via the stub interface Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 010/103] dm btree: fix for dm_btree_find_lowest_key() Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 011/103] dm raid: select the Kconfig option CONFIG_MD_RAID0 Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 012/103] dm bufio: avoid a possible ABBA deadlock Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 013/103] dm bufio: check new buffer allocation watermark every 30 seconds Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 014/103] dm cache metadata: fail operations if fail_io mode has been established Greg Kroah-Hartman
2017-05-23 20:08 ` Greg Kroah-Hartman [this message]
2017-05-23 20:08 ` [PATCH 4.4 016/103] dm thin metadata: call precommit before saving the roots Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 017/103] dm space map disk: fix some book keeping in the disk space map Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 018/103] md: update slab_cache before releasing new stripes when stripes resizing Greg Kroah-Hartman
2017-05-30 13:16   ` Ben Hutchings
2017-05-30 17:27     ` Shaohua Li
2017-05-23 20:08 ` [PATCH 4.4 019/103] rtlwifi: rtl8821ae: setup 8812ae RFE according to device type Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 020/103] mwifiex: pcie: fix cmd_buf use-after-free in remove/reset Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 024/103] regulator: tps65023: Fix inverted core enable logic Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 025/103] s390/kdump: Add final note Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 026/103] s390/cputime: fix incorrect system time Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 027/103] ath9k_htc: Add support of AirTies 1eda:2315 AR9271 device Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 028/103] ath9k_htc: fix NULL-deref at probe Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 029/103] drm/amdgpu: Avoid overflows/divide-by-zero in latency_watermark calculations Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 030/103] drm/amdgpu: Make display watermark calculations more accurate Greg Kroah-Hartman
2017-06-01 11:13   ` Ben Hutchings
2017-06-06 17:46     ` Mario Kleiner
2017-06-08 10:49       ` Ben Hutchings
2017-05-23 20:08 ` [PATCH 4.4 031/103] drm/nouveau/therm: remove ineffective workarounds for alarm bugs Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 032/103] drm/nouveau/tmr: ack interrupt before processing alarms Greg Kroah-Hartman
2017-05-23 20:08 ` [PATCH 4.4 033/103] drm/nouveau/tmr: fix corruption of the pending list when rescheduling an alarm Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 034/103] drm/nouveau/tmr: avoid processing completed alarms when adding a new one Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 035/103] drm/nouveau/tmr: handle races with hw when updating the next alarm time Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 036/103] cdc-acm: fix possible invalid access when processing notification Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 037/103] proc: Fix unbalanced hard link numbers Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 038/103] of: fix sparse warning in of_pci_range_parser_one Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 039/103] iio: dac: ad7303: fix channel description Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 040/103] pid_ns: Sleep in TASK_INTERRUPTIBLE in zap_pid_ns_processes Greg Kroah-Hartman
2017-06-01 11:55   ` Ben Hutchings
2017-06-01 13:44     ` Eric W. Biederman
2017-05-23 20:09 ` [PATCH 4.4 041/103] pid_ns: Fix race between setnsed fork() and zap_pid_ns_processes() Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 042/103] USB: serial: ftdi_sio: fix setting latency for unprivileged users Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 043/103] USB: serial: ftdi_sio: add Olimex ARM-USB-TINY(H) PIDs Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 044/103] ext4 crypto: dont let data integrity writebacks fail with ENOMEM Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 045/103] ext4 crypto: fix some error handling Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 047/103] fscrypt: fix context consistency check when key(s) unavailable Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 048/103] f2fs: check entire encrypted bigname when finding a dentry Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 049/103] fscrypt: avoid collisions when presenting long encrypted filenames Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 050/103] sched/fair: Do not announce throttled next buddy in dequeue_task_fair() Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 051/103] sched/fair: Initialize throttle_count for new task-groups lazily Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 052/103] usb: host: xhci-plat: propagate return value of platform_get_irq() Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 053/103] xhci: apply PME_STUCK_QUIRK and MISSING_CAS quirk for Denverton Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 054/103] usb: host: xhci-mem: allocate zeroed Scratchpad Buffer Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 055/103] net: irda: irda-usb: fix firmware name on big-endian hosts Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 056/103] [media] usbvision: fix NULL-deref at probe Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 057/103] [media] mceusb: " Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 058/103] [media] ttusb2: limit messages to buffer size Greg Kroah-Hartman
2017-06-02 10:28   ` Ben Hutchings
2017-05-23 20:09 ` [PATCH 4.4 059/103] usb: musb: tusb6010_omap: Do not reset the other directions packet size Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 060/103] USB: iowarrior: fix info ioctl on big-endian hosts Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 061/103] usb: serial: option: add Telit ME910 support Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 063/103] USB: serial: mct_u232: fix big-endian baud-rate handling Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 064/103] USB: serial: io_ti: fix div-by-zero in set_termios Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 065/103] USB: hub: fix SS hub-descriptor handling Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 066/103] USB: hub: fix non-SS " Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 067/103] tty: Prevent ldisc drivers from re-using stale tty fields Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 069/103] iio: proximity: as3935: fix as3935_write Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 071/103] [media] gspca: konica: add missing endpoint sanity check Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 072/103] [media] s5p-mfc: Fix unbalanced call to clock management Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 073/103] [media] dib0700: fix NULL-deref at probe Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 074/103] [media] zr364xx: enforce minimum size when reading header Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 075/103] [media] dvb-frontends/cxd2841er: define symbol_rate_min/max in T/C fe-ops Greg Kroah-Hartman
2017-06-02 11:34   ` Ben Hutchings
2017-05-23 20:09 ` [PATCH 4.4 076/103] [media] cx231xx-audio: fix init error path Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 077/103] [media] cx231xx-audio: fix NULL-deref at probe Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 078/103] [media] cx231xx-cards: " Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 079/103] powerpc/book3s/mce: Move add_taint() later in virtual mode Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 080/103] powerpc/pseries: Fix of_node_put() underflow during DLPAR remove Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 081/103] powerpc/64e: Fix hang when debugging programs with relocated kernel Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 082/103] ARM: dts: at91: sama5d3_xplained: fix ADC vref Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 083/103] ARM: dts: at91: sama5d3_xplained: not all ADC channels are available Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 084/103] arm64: xchg: hazard against entire exchange variable Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 085/103] arm64: uaccess: ensure extension of access_ok() addr Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 086/103] arm64: documentation: document tagged pointer stack constraints Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 087/103] xc2028: Fix use-after-free bug properly Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 088/103] mm/huge_memory.c: respect FOLL_FORCE/FOLL_COW for thp Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 089/103] staging: rtl8192e: fix 2 byte alignment of register BSSIDR Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 090/103] staging: rtl8192e: rtl92e_get_eeprom_size Fix read size of EPROM_CMD Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 091/103] iommu/vt-d: Flush the IOTLB to get rid of the initial kdump mappings Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 092/103] metag/uaccess: Fix access_ok() Greg Kroah-Hartman
2017-05-23 20:09   ` Greg Kroah-Hartman
2017-05-23 20:09 ` [PATCH 4.4 093/103] metag/uaccess: Check access_ok in strncpy_from_user Greg Kroah-Hartman
2017-05-23 20:10 ` [PATCH 4.4 094/103] stackprotector: Increase the per-task stack canarys random range from 32 bits to 64 bits on 64-bit platforms Greg Kroah-Hartman
2017-05-23 20:10   ` [kernel-hardening] " Greg Kroah-Hartman
2017-05-23 20:10 ` [PATCH 4.4 095/103] uwb: fix device quirk on big-endian hosts Greg Kroah-Hartman
2017-05-23 20:10 ` [PATCH 4.4 096/103] genirq: Fix chained interrupt data ordering Greg Kroah-Hartman
2017-05-23 20:10 ` [PATCH 4.4 097/103] osf_wait4(): fix infoleak Greg Kroah-Hartman
2017-05-23 20:10 ` [PATCH 4.4 098/103] tracing/kprobes: Enforce kprobes teardown after testing Greg Kroah-Hartman
2017-05-23 20:10 ` [PATCH 4.4 099/103] PCI: Fix pci_mmap_fits() for HAVE_PCI_RESOURCE_TO_USER platforms Greg Kroah-Hartman
2017-05-23 20:10 ` [PATCH 4.4 101/103] drm/edid: Add 10 bpc quirk for LGD 764 panel in HP zBook 17 G2 Greg Kroah-Hartman
2017-05-23 20:10 ` [PATCH 4.4 102/103] nfsd: encoders mustnt use unitialized values in error cases Greg Kroah-Hartman
2017-05-23 20:10 ` [PATCH 4.4 103/103] drivers: char: mem: Check for address space wraparound with mmap() Greg Kroah-Hartman
2017-05-24  4:01 ` [PATCH 4.4 000/103] 4.4.70-stable review Guenter Roeck
2017-05-24  6:50   ` Greg Kroah-Hartman
2017-05-24  6:55     ` Greg Kroah-Hartman
     [not found] ` <59252147.91471c0a.7a474.26e6@mx.google.com>
2017-05-24  7:03   ` Greg Kroah-Hartman
2017-05-24  9:26     ` Thomas Voegtle
2017-05-24 11:35       ` Greg Kroah-Hartman
2017-05-24 12:04         ` Thomas Voegtle
2017-05-24 12:53           ` Greg Kroah-Hartman
2017-05-24 12:47     ` Guenter Roeck
2017-05-24 12:58       ` Mark Brown
2017-05-24 13:18         ` Guenter Roeck
2017-05-24 15:08           ` Mark Brown
2017-05-24 13:33         ` Guenter Roeck
2017-05-24 20:22 ` 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=20170523200858.673632398@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.