From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org, "Joel Becker" <jlbec@evilplan.org>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Ashish Samant" <ashish.samant@oracle.com>,
"Mark Fasheh" <mfasheh@versity.com>,
"Junxiao Bi" <junxiao.bi@oracle.com>,
"Joseph Qi" <jiangqi903@gmail.com>
Subject: [PATCH 3.2 72/94] ocfs2: fstrim: Fix start offset of first cluster group during fstrim
Date: Thu, 28 Dec 2017 16:59:12 +0000 [thread overview]
Message-ID: <lsq.1514480352.272348919@decadent.org.uk> (raw)
In-Reply-To: <lsq.1514480348.981935392@decadent.org.uk>
3.2.97-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ashish Samant <ashish.samant@oracle.com>
commit 105ddc93f06ebe3e553f58563d11ed63dbcd59f0 upstream.
The first cluster group descriptor is not stored at the start of the
group but at an offset from the start. We need to take this into
account while doing fstrim on the first cluster group. Otherwise we
will wrongly start fstrim a few blocks after the desired start block and
the range can cross over into the next cluster group and zero out the
group descriptor there. This can cause filesytem corruption that cannot
be fixed by fsck.
Link: http://lkml.kernel.org/r/1507835579-7308-1-git-send-email-ashish.samant@oracle.com
Signed-off-by: Ashish Samant <ashish.samant@oracle.com>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
Reviewed-by: Joseph Qi <jiangqi903@gmail.com>
Cc: Mark Fasheh <mfasheh@versity.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
fs/ocfs2/alloc.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -7188,13 +7188,24 @@ out:
static int ocfs2_trim_extent(struct super_block *sb,
struct ocfs2_group_desc *gd,
- u32 start, u32 count)
+ u64 group, u32 start, u32 count)
{
u64 discard, bcount;
+ struct ocfs2_super *osb = OCFS2_SB(sb);
bcount = ocfs2_clusters_to_blocks(sb, count);
- discard = le64_to_cpu(gd->bg_blkno) +
- ocfs2_clusters_to_blocks(sb, start);
+ discard = ocfs2_clusters_to_blocks(sb, start);
+
+ /*
+ * For the first cluster group, the gd->bg_blkno is not at the start
+ * of the group, but at an offset from the start. If we add it while
+ * calculating discard for first group, we will wrongly start fstrim a
+ * few blocks after the desried start block and the range can cross
+ * over into the next cluster group. So, add it only if this is not
+ * the first cluster group.
+ */
+ if (group != osb->first_cluster_group_blkno)
+ discard += le64_to_cpu(gd->bg_blkno);
trace_ocfs2_trim_extent(sb, (unsigned long long)discard, bcount);
@@ -7202,7 +7213,7 @@ static int ocfs2_trim_extent(struct supe
}
static int ocfs2_trim_group(struct super_block *sb,
- struct ocfs2_group_desc *gd,
+ struct ocfs2_group_desc *gd, u64 group,
u32 start, u32 max, u32 minbits)
{
int ret = 0, count = 0, next;
@@ -7221,7 +7232,7 @@ static int ocfs2_trim_group(struct super
next = ocfs2_find_next_bit(bitmap, max, start);
if ((next - start) >= minbits) {
- ret = ocfs2_trim_extent(sb, gd,
+ ret = ocfs2_trim_extent(sb, gd, group,
start, next - start);
if (ret < 0) {
mlog_errno(ret);
@@ -7323,7 +7334,8 @@ int ocfs2_trim_fs(struct super_block *sb
}
gd = (struct ocfs2_group_desc *)gd_bh->b_data;
- cnt = ocfs2_trim_group(sb, gd, first_bit, last_bit, minlen);
+ cnt = ocfs2_trim_group(sb, gd, group,
+ first_bit, last_bit, minlen);
brelse(gd_bh);
gd_bh = NULL;
if (cnt < 0) {
next prev parent reply other threads:[~2017-12-28 18:08 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-28 16:59 [PATCH 3.2 00/94] 3.2.97-rc1 review Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 31/94] sched/sysctl: Check user input value of sysctl_sched_time_avg Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 15/94] usb-storage: unusual_devs entry to fix write-access regression for Seagate external drives Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 77/94] ALSA: timer: Limit max instances per timer Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 14/94] Input: uinput - avoid FF flush when destroying device Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 17/94] USB: gadgetfs: fix copy_to_user while holding spinlock Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 80/94] ALSA: seq: Fix OSS sysex delivery in OSS emulation Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 44/94] ALSA: seq: Fix copy_from_user() call inside lock Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 60/94] usb: quirks: add quirk for WORLDE MINI MIDI keyboard Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 01/94] tile: array underflow in setup_maxnodemem() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 66/94] ALSA: seq: Fix nested rwsem annotation for lockdep splat Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 38/94] kernel/params.c: align add_sysfs_param documentation with code Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 92/94] crypto: salsa20 - fix blkcipher_walk API usage Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 62/94] ipsec: Fix aborted xfrm policy dump crash Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 04/94] USB: serial: ftdi_sio: add id for Cypress WICED dev board Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 07/94] uwb: properly check kthread_run return value Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 91/94] KVM: Fix stack-out-of-bounds read in write_mmio Ben Hutchings
2017-12-28 16:59 ` Ben Hutchings [this message]
2017-12-28 16:59 ` [PATCH 3.2 41/94] Smack: remove unneeded NULL-termination from securtity label Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 88/94] KVM: VMX: remove I/O port 0x80 bypass on Intel hosts Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 27/94] USB: dummy-hcd: Fix erroneous synchronization change Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 78/94] ARM: 8720/1: ensure dump_instr() checks addr_limit Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 37/94] scsi: sd: Implement blacklist option for WRITE SAME w/ UNMAP Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 26/94] USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 40/94] sh: sh7757: remove nonexistent GPIO_PT[JLNQ]7_RESV to fix pinctrl registration Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 84/94] Bluetooth: hidp: verify l2cap sockets Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 34/94] staging: iio: ade7759: fix signed extension bug on shift of a u8 Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 46/94] more bio_map_user_iov() leak fixes Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 51/94] KVM: nVMX: fix guest CR4 loading when emulating L2 to L1 exit Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 56/94] l2tp: check ps->sock before running pppol2tp_session_ioctl() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 73/94] l2tp: hold socket before dropping lock in l2tp_ip{, 6}_recv() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 19/94] KEYS: fix cred refcount leak in request_key_auth_new() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 70/94] KEYS: trusted: sanitize all key material Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 20/94] KEYS: don't revoke uninstantiated key in request_key_auth_new() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 32/94] KVM: Do not take reference to mm during async #PF Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 93/94] crypto: hmac - require that the underlying hash algorithm is unkeyed Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 85/94] Bluetooth: cmtp: cmtp_add_connection() should verify that it's dealing with l2cap socket Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 81/94] x86/oprofile/ppro: Do not use __this_cpu*() in preemptible context Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 47/94] USB: dummy-hcd: Fix deadlock caused by disconnect detection Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 29/94] usb: renesas_usbhs: fix usbhsf_fifo_clear() for RX direction Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 83/94] dccp: CVE-2017-8824: use-after-free in DCCP code Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 39/94] sh: sh7722: remove nonexistent GPIO_PTQ7 to fix pinctrl registration Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 13/94] crypto: talitos - fix sha224 Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 63/94] sctp: fix a type cast warnings that causes a_rwnd gets the wrong value Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 49/94] ALSA: caiaq: Fix stray URB at probe error path Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 12/94] USB: serial: cp210x: add support for ELV TFD500 Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 43/94] kvm/x86: Avoid async PF preempting the kernel incorrectly Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 28/94] usb: renesas_usbhs: fix the BCLR setting condition for non-DCP pipe Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 03/94] scsi: lpfc: Don't return internal MBXERR_ERROR code from probe function Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 69/94] tcp: fix tcp_mtu_probe() vs highest_sack Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 90/94] ptrace: change __ptrace_unlink() to clear ->ptrace under ->siglock Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 16/94] usb: gadget: fix spinlock dead lock in gadgetfs Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 75/94] l2tp: don't use l2tp_tunnel_find() in l2tp_ip and l2tp_ip6 Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 45/94] crypto: shash - Fix zero-length shash ahash digest crash Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 05/94] USB: serial: option: add support for TP-Link LTE module Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 55/94] iommu/amd: Finish TLB flush in amd_iommu_unmap() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 21/94] KEYS: fix key refcount leak in keyctl_assume_authority() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 76/94] ALSA: timer: Protect the whole snd_timer_close() with open race Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 36/94] ALSA: usx2y: Suppress kernel warning at page allocation failures Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 54/94] ecryptfs: fix dereference of NULL user_key_payload Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 23/94] KEYS: prevent creating a different user's keyrings Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 65/94] ALSA: timer: Add missing mutex lock for compat ioctls Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 02/94] spi: uapi: spidev: add missing ioctl header Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 22/94] KEYS: fix key refcount leak in keyctl_read_key() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 82/94] MIPS: AR7: Ensure that serial ports are properly set up Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 61/94] can: esd_usb2: Fix can_dlc value for received RTR, frames Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 52/94] KEYS: encrypted: fix dereference of NULL user_key_payload Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 35/94] l2tp: fix l2tp_eth module loading Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 30/94] packet: only test po->has_vnet_hdr once in packet_snd Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 59/94] usb: cdc_acm: Add quirk for Elatec TWN3 Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 42/94] lsm: fix smack_inode_removexattr and xattr_getsecurity memleak Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 87/94] USB: core: prevent malicious bNumInterfaces overflow Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 74/94] l2tp: hold tunnel socket when handling control frames in l2tp_ip and l2tp_ip6 Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 50/94] scsi: libiscsi: fix shifting of DID_REQUEUE host byte Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 10/94] usb: pci-quirks.c: Corrected timeout values used in handshake Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 48/94] usb: renesas_usbhs: Fix DMAC sequence for receiving zero-length packet Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 53/94] FS-Cache: fix dereference of NULL user_key_payload Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 58/94] scsi: zfcp: fix erp_action use-before-initialize in REC action trace Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 86/94] Bluetooth: bnep: bnep_add_connection() should verify that it's dealing with l2cap socket Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 79/94] ALSA: seq: Avoid invalid lockdep class warning Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 06/94] uwb: ensure that endpoint is interrupt Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 08/94] usb: Increase quirk delay for USB devices Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 67/94] macvtap: fix TUNSETSNDBUF values > 64k Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 25/94] USB: dummy-hcd: fix infinite-loop resubmission bug Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 64/94] l2tp: hold tunnel in pppol2tp_connect() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 09/94] xhci: fix finding correct bus_state structure for USB 3.1 hosts Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 94/94] KEYS: add missing permission check for request_key() destination Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 57/94] net: enable interface alias removal via rtnl Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 24/94] vfs: Return -ENXIO for negative SEEK_HOLE / SEEK_DATA offsets Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 71/94] KEYS: trusted: fix writing past end of buffer in trusted_read() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 18/94] USB: gadgetfs: Fix crash caused by inadequate synchronization Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 68/94] tun/tap: sanitize TUNSETSNDBUF input Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 89/94] security: Fix mode test in selinux_ptrace_access_check() Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 33/94] kvm/x86: Handle async PF in RCU read-side critical sections Ben Hutchings
2017-12-28 16:59 ` [PATCH 3.2 11/94] s390/mm: fix write access check in gup_huge_pmd() Ben Hutchings
2017-12-28 19:26 ` [PATCH 3.2 00/94] 3.2.97-rc1 review 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.1514480352.272348919@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=akpm@linux-foundation.org \
--cc=ashish.samant@oracle.com \
--cc=jiangqi903@gmail.com \
--cc=jlbec@evilplan.org \
--cc=junxiao.bi@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mfasheh@versity.com \
--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
all inboxes | Powered by JetHome®