+ fix-clusters-leak-in-ocfs2_defrag_extent.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: ocfs2: fix clusters leak in ocfs2_defrag_extent()
has been added to the -mm tree.  Its filename is
     fix-clusters-leak-in-ocfs2_defrag_extent.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/fix-clusters-leak-in-ocfs2_defrag_extent.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/fix-clusters-leak-in-ocfs2_defrag_extent.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Larry Chen <lchen@xxxxxxxx>
Subject: ocfs2: fix clusters leak in ocfs2_defrag_extent()

ocfs2_defrag_extent() might leak allocated clusters.  When the file system
has insufficient space, the number of claimed clusters might be less than
the caller wants.  If that happens, the original code might directly
commit the transaction without returning clusters.

This patch is based on code in ocfs2_add_clusters_in_btree().

Link: http://lkml.kernel.org/r/20180904041621.16874-3-lchen@xxxxxxxx
Signed-off-by: Larry Chen <lchen@xxxxxxxx>
Cc: Mark Fasheh <mark@xxxxxxxxxx>
Cc: Joel Becker <jlbec@xxxxxxxxxxxx>
Cc: Junxiao Bi <junxiao.bi@xxxxxxxxxx>
Cc: Joseph Qi <jiangqi903@xxxxxxxxx>
Cc: Changwei Ge <ge.changwei@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 fs/ocfs2/move_extents.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

--- a/fs/ocfs2/move_extents.c~fix-clusters-leak-in-ocfs2_defrag_extent
+++ a/fs/ocfs2/move_extents.c
@@ -226,6 +226,8 @@ static int ocfs2_defrag_extent(struct oc
 	struct ocfs2_refcount_tree *ref_tree = NULL;
 	u32 new_phys_cpos, new_len;
 	u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
+	int need_free = 0;
+	struct ocfs2_alloc_context *data_ac;
 
 	if ((ext_flags & OCFS2_EXT_REFCOUNTED) && *len) {
 		BUG_ON(!ocfs2_is_refcount_inode(inode));
@@ -317,6 +319,7 @@ static int ocfs2_defrag_extent(struct oc
 		if (!partial) {
 			context->range->me_flags &= ~OCFS2_MOVE_EXT_FL_COMPLETE;
 			ret = -ENOSPC;
+			need_free = 1;
 			goto out_commit;
 		}
 	}
@@ -341,6 +344,19 @@ static int ocfs2_defrag_extent(struct oc
 		mlog_errno(ret);
 
 out_commit:
+	if (need_free && context->data_ac) {
+		data_ac = context->data_ac;
+		if (context->data_ac->ac_which == OCFS2_AC_USE_LOCAL)
+			ocfs2_free_local_alloc_bits(osb, handle, data_ac,
+					new_phys_cpos, new_len);
+		else
+			ocfs2_free_clusters(handle,
+					data_ac->ac_inode,
+					data_ac->ac_bh,
+					ocfs2_clusters_to_blocks(osb->sb, new_phys_cpos),
+					new_len);
+	}
+
 	ocfs2_commit_trans(osb, handle);
 
 out_unlock_mutex:
_

Patches currently in -mm which might be from lchen@xxxxxxxx are

fix-crash-on-ocfs2_duplicate_clusters_by_page.patch
fix-crash-on-ocfs2_duplicate_clusters_by_page-v5.patch
fix-dead-lock-caused-by-ocfs2_defrag_extent.patch
ocfs2-fix-dead-lock-caused-by-ocfs2_defrag_extent.patch
fix-clusters-leak-in-ocfs2_defrag_extent.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux