1. 20 2月, 2011 1 次提交
  2. 11 9月, 2010 1 次提交
    • T
      ocfs2: Fix lockdep warning in reflink. · 07eaac94
      Tao Ma 提交于
      This patch change mutex_lock to a new subclass and
      add a new inode lock subclass for the target inode
      which caused this lockdep warning.
      
      =============================================
      [ INFO: possible recursive locking detected ]
      2.6.35+ #5
      ---------------------------------------------
      reflink/11086 is trying to acquire lock:
       (Meta){+++++.}, at: [<ffffffffa06f9d65>] ocfs2_reflink_ioctl+0x898/0x1229 [ocfs2]
      
      but task is already holding lock:
       (Meta){+++++.}, at: [<ffffffffa06f9aa0>] ocfs2_reflink_ioctl+0x5d3/0x1229 [ocfs2]
      
      other info that might help us debug this:
      6 locks held by reflink/11086:
       #0:  (&sb->s_type->i_mutex_key#15/1){+.+.+.}, at: [<ffffffff820e09ec>] lookup_create+0x26/0x97
       #1:  (&sb->s_type->i_mutex_key#15){+.+.+.}, at: [<ffffffffa06f99a0>] ocfs2_reflink_ioctl+0x4d3/0x1229 [ocfs2]
       #2:  (Meta){+++++.}, at: [<ffffffffa06f9aa0>] ocfs2_reflink_ioctl+0x5d3/0x1229 [ocfs2]
       #3:  (&oi->ip_xattr_sem){+.+.+.}, at: [<ffffffffa06f9b58>] ocfs2_reflink_ioctl+0x68b/0x1229 [ocfs2]
       #4:  (&oi->ip_alloc_sem){+.+.+.}, at: [<ffffffffa06f9b67>] ocfs2_reflink_ioctl+0x69a/0x1229 [ocfs2]
       #5:  (&sb->s_type->i_mutex_key#15/2){+.+...}, at: [<ffffffffa06f9d4f>] ocfs2_reflink_ioctl+0x882/0x1229 [ocfs2]
      
      stack backtrace:
      Pid: 11086, comm: reflink Not tainted 2.6.35+ #5
      Call Trace:
       [<ffffffff82063dd9>] validate_chain+0x56e/0xd68
       [<ffffffff82062275>] ? mark_held_locks+0x49/0x69
       [<ffffffff82064d6d>] __lock_acquire+0x79a/0x7f1
       [<ffffffff82065a81>] lock_acquire+0xc6/0xed
       [<ffffffffa06f9d65>] ? ocfs2_reflink_ioctl+0x898/0x1229 [ocfs2]
       [<ffffffffa06c9ade>] __ocfs2_cluster_lock+0x975/0xa0d [ocfs2]
       [<ffffffffa06f9d65>] ? ocfs2_reflink_ioctl+0x898/0x1229 [ocfs2]
       [<ffffffffa06e107b>] ? ocfs2_wait_for_recovery+0x15/0x8a [ocfs2]
       [<ffffffffa06cb6ea>] ocfs2_inode_lock_full_nested+0x1ac/0xdc5 [ocfs2]
       [<ffffffffa06f9d65>] ? ocfs2_reflink_ioctl+0x898/0x1229 [ocfs2]
       [<ffffffff820623a0>] ? trace_hardirqs_on_caller+0x10b/0x12f
       [<ffffffff82060193>] ? debug_mutex_free_waiter+0x4f/0x53
       [<ffffffffa06f9d65>] ocfs2_reflink_ioctl+0x898/0x1229 [ocfs2]
       [<ffffffffa06ce24a>] ? ocfs2_file_lock_res_init+0x66/0x78 [ocfs2]
       [<ffffffff820bb2d2>] ? might_fault+0x40/0x8d
       [<ffffffffa06df9f6>] ocfs2_ioctl+0x61a/0x656 [ocfs2]
       [<ffffffff820ee5d3>] ? mntput_no_expire+0x1d/0xb0
       [<ffffffff820e07b3>] ? path_put+0x2c/0x31
       [<ffffffff820e53ac>] vfs_ioctl+0x2a/0x9d
       [<ffffffff820e5903>] do_vfs_ioctl+0x45d/0x4ae
       [<ffffffff8233a7f6>] ? _raw_spin_unlock+0x26/0x2a
       [<ffffffff8200299c>] ? sysret_check+0x27/0x62
       [<ffffffff820e59ab>] sys_ioctl+0x57/0x7a
       [<ffffffff8200296b>] system_call_fastpath+0x16/0x1b
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      07eaac94
  3. 08 9月, 2010 1 次提交
  4. 12 8月, 2010 3 次提交
  5. 08 8月, 2010 1 次提交
  6. 16 7月, 2010 1 次提交
  7. 09 7月, 2010 1 次提交
    • J
      ocfs2: Zero the tail cluster when extending past i_size. · 5693486b
      Joel Becker 提交于
      ocfs2's allocation unit is the cluster.  This can be larger than a block
      or even a memory page.  This means that a file may have many blocks in
      its last extent that are beyond the block containing i_size.  There also
      may be more unwritten extents after that.
      
      When ocfs2 grows a file, it zeros the entire cluster in order to ensure
      future i_size growth will see cleared blocks.  Unfortunately,
      block_write_full_page() drops the pages past i_size.  This means that
      ocfs2 is actually leaking garbage data into the tail end of that last
      cluster.  This is a bug.
      
      We adjust ocfs2_write_begin_nolock() and ocfs2_extend_file() to detect
      when a write or truncate is past i_size.  They will use
      ocfs2_zero_extend() to ensure the data is properly zeroed.
      
      Older versions of ocfs2_zero_extend() simply zeroed every block between
      i_size and the zeroing position.  This presumes three things:
      
      1) There is allocation for all of these blocks.
      2) The extents are not unwritten.
      3) The extents are not refcounted.
      
      (1) and (2) hold true for non-sparse filesystems, which used to be the
      only users of ocfs2_zero_extend().  (3) is another bug.
      
      Since we're now using ocfs2_zero_extend() for sparse filesystems as
      well, we teach ocfs2_zero_extend() to check every extent between
      i_size and the zeroing position.  If the extent is unwritten, it is
      ignored.  If it is refcounted, it is CoWed.  Then it is zeroed.
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      Cc: stable@kernel.org
      5693486b
  8. 19 5月, 2010 1 次提交
    • T
      Ocfs2: Optimize ocfs2 truncate to use ocfs2_remove_btree_range() instead. · 78f94673
      Tristan Ye 提交于
      Truncate is just a special case of punching holes(from new i_size to
      end), we therefore could take advantage of the existing
      ocfs2_remove_btree_range() to reduce the comlexity and redundancy in
      alloc.c.  The goal here is to make truncate more generic and
      straightforward.
      
      Several functions only used by ocfs2_commit_truncate() will smiply be
      removed.
      
      ocfs2_remove_btree_range() was originally used by the hole punching
      code, which didn't take refcount trees into account (definitely a bug).
      We therefore need to change that func a bit to handle refcount trees.
      It must take the refcount lock, calculate and reserve blocks for
      refcount tree changes, and decrease refcounts at the end.  We replace 
      ocfs2_lock_allocators() here by adding a new func
      ocfs2_reserve_blocks_for_rec_trunc() which accepts some extra blocks to
      reserve.  This will not hurt any other code using
      ocfs2_remove_btree_range() (such as dir truncate and hole punching).
      
      I merged the following steps into one patch since they may be
      logically doing one thing, though I know it looks a little bit fat
      to review.
      
      1). Remove redundant code used by ocfs2_commit_truncate(), since we're
          moving to ocfs2_remove_btree_range anyway.
      
      2). Add a new func ocfs2_reserve_blocks_for_rec_trunc() for purpose of
          accepting some extra blocks to reserve.
      
      3). Change ocfs2_prepare_refcount_change_for_del() a bit to fit our
          needs.  It's safe to do this since it's only being called by
          truncate.
      
      4). Change ocfs2_remove_btree_range() a bit to take refcount case into
          account.
      
      5). Finally, we change ocfs2_commit_truncate() to call
          ocfs2_remove_btree_range() in a proper way.
      
      The patch has been tested normally for sanity check, stress tests
      with heavier workload will be expected.
      
      Based on this patch, fixing the punching holes bug will be fairly easy.
      Signed-off-by: NTristan Ye <tristan.ye@oracle.com>
      Acked-by: NMark Fasheh <mfasheh@suse.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      78f94673
  9. 06 5月, 2010 2 次提交
    • T
      ocfs2: Make ocfs2_extend_trans() really extend. · c901fb00
      Tao Ma 提交于
      In ocfs2, we use ocfs2_extend_trans() to extend a journal handle's
      blocks. But if jbd2_journal_extend() fails, it will only restart
      with the the new number of blocks.  This tends to be awkward since
      in most cases we want additional reserved blocks. It makes our code
      harder to mantain since the caller can't be sure all the original
      blocks will not be accessed and dirtied again.  There are 15 callers
      of ocfs2_extend_trans() in fs/ocfs2, and 12 of them have to add
      h_buffer_credits before they call ocfs2_extend_trans().  This makes
      ocfs2_extend_trans() really extend atop the original block count.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      c901fb00
    • J
      ocfs2: Make ocfs2_journal_dirty() void. · ec20cec7
      Joel Becker 提交于
      jbd[2]_journal_dirty_metadata() only returns 0.  It's been returning 0
      since before the kernel moved to git.  There is no point in checking
      this error.
      
      ocfs2_journal_dirty() has been faithfully returning the status since the
      beginning.  All over ocfs2, we have blocks of code checking this can't
      fail status.  In the past few years, we've tried to avoid adding these
      checks, because they are pointless.  But anyone who looks at our code
      assumes they are needed.
      
      Finally, ocfs2_journal_dirty() is made a void function.  All error
      checking is removed from other files.  We'll BUG_ON() the status of
      jbd2_journal_dirty_metadata() just in case they change it someday.  They
      won't.
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      ec20cec7
  10. 24 4月, 2010 1 次提交
  11. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  12. 22 3月, 2010 1 次提交
  13. 26 3月, 2010 1 次提交
  14. 06 5月, 2010 1 次提交
  15. 18 3月, 2010 1 次提交
  16. 05 3月, 2010 1 次提交
    • C
      dquot: cleanup dquot initialize routine · 871a2931
      Christoph Hellwig 提交于
      Get rid of the initialize dquot operation - it is now always called from
      the filesystem and if a filesystem really needs it's own (which none
      currently does) it can just call into it's own routine directly.
      
      Rename the now static low-level dquot_initialize helper to __dquot_initialize
      and vfs_dq_init to dquot_initialize to have a consistent namespace.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      871a2931
  17. 27 2月, 2010 1 次提交
  18. 03 2月, 2010 2 次提交
    • T
      ocfs2: Only bug out when page size is larger than cluster size. · 0a1ea437
      Tao Ma 提交于
      In CoW, we have to make sure that the page is already written
      out to the disk. So we have a BUG_ON(PageDirty(page)).
      
      In ppc platform we have pagesize=64K, so if the cs=4K, if the
      file have fragmented clusters, we will map the page many times.
      See this file as an example.
      Tree Depth: 0   Count: 19   Next Free Rec: 14
      	## Offset        Clusters       Block#          Flags
      	0  0             4              2164864         0x2 Refcounted
      	1  4             2              9302792         0x2 Refcounted
      ...
      
      We have to replace the extent recs one by one, so the page with index 0
      will be mapped and dirtied twice.
      
      I'd like to leave the BUG_ON there while adding a check so that in
      case we meet with an error in other platforms, we can find it easily.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      0a1ea437
    • T
      ocfs2: Fix memory overflow in cow_by_page. · d622b89a
      Tao Ma 提交于
      In ocfs2_duplicate_clusters_by_page, we calculate map_end
      by shifting page_index. But actually in case we meet with
      a large offset(say in a i686 box, poff_t is only 32 bits
      and page_index=2056240), we will overflow. So change the
      type of page_index to loff_t.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      d622b89a
  19. 04 12月, 2009 1 次提交
  20. 03 12月, 2009 2 次提交
    • T
      ocfs2: refcounttree.c cleanup. · 12d4cec9
      Tao Ma 提交于
      sparse check finds some endian problem and some other minor issues.
      There is an obsolete function which should be removed.
      So this patch resolve all these.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      12d4cec9
    • T
      ocfs2: Find proper end cpos for a leaf refcount block. · 38a04e43
      Tao Ma 提交于
      ocfs2 refcount tree is stored as an extent tree while
      the leaf ocfs2_refcount_rec points to a refcount block.
      
      The following step can trip a kernel panic.
      mkfs.ocfs2 -b 512 -C 1M --fs-features=refcount $DEVICE
      mount -t ocfs2 $DEVICE $MNT_DIR
      FILE_NAME=$RANDOM
      FILE_NAME_1=$RANDOM
      FILE_REF="${FILE_NAME}_ref"
      FILE_REF_1="${FILE_NAME}_ref_1"
      for((i=0;i<305;i++))
      do
      # /mnt/1048576 is a file with 1048576 sizes.
      cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME
      cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME_1
      done
      for((i=0;i<3;i++))
      do
      cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME
      done
      
      for((i=0;i<2;i++))
      do
      cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME
      cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME_1
      done
      
      cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME
      
      for((i=0;i<11;i++))
      do
      cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME
      cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME_1
      done
      reflink $MNT_DIR/$FILE_NAME $MNT_DIR/$FILE_REF
      # write_f is a program which will write some bytes to a file at offset.
      # write_f -f file_name -l offset -w write_bytes.
      ./write_f -f $MNT_DIR/$FILE_REF -l $[310*1048576] -w 4096
      ./write_f -f $MNT_DIR/$FILE_REF -l $[306*1048576] -w 4096
      ./write_f -f $MNT_DIR/$FILE_REF -l $[311*1048576] -w 4096
      ./write_f -f $MNT_DIR/$FILE_NAME -l $[310*1048576] -w 4096
      ./write_f -f $MNT_DIR/$FILE_NAME -l $[311*1048576] -w 4096
      reflink $MNT_DIR/$FILE_NAME $MNT_DIR/$FILE_REF_1
      ./write_f -f $MNT_DIR/$FILE_NAME -l $[311*1048576] -w 4096
      #kernel panic here.
      
      The reason is that if the ocfs2_extent_rec is the last record
      in a leaf extent block, the old solution fails to find the
      suitable end cpos. So this patch try to walk through the b-tree,
      find the next sub root and get the c_pos the next sub-tree starts
      from.
      
      btw, I have runned tristan's test case against the patched kernel
      for several days and this type of kernel panic never happens again.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      38a04e43
  21. 29 10月, 2009 2 次提交
  22. 23 9月, 2009 13 次提交
    • T
      ocfs2: Add ioctl for reflink. · bd50873d
      Tao Ma 提交于
      The ioctl will take 3 parameters: old_path, new_path and
      preserve and call vfs_reflink. It is useful when we backport
      reflink features to old kernels.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      bd50873d
    • T
      ocfs2: Implement ocfs2_reflink. · 09bf27a0
      Tao Ma 提交于
      Implement ocfs2_reflink.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      09bf27a0
    • T
      ocfs2: Add preserve to reflink. · 0fe9b66c
      Tao Ma 提交于
      reflink has 2 options for the destination file:
      1. snapshot: reflink will attempt to preserve ownership, permissions,
         and all other security state in order to create a full snapshot.
      2. new file: it will acquire the data extent sharing but will see the
         file's security state and attributes initialized as a new file.
      
      So add the option to ocfs2.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      0fe9b66c
    • T
      ocfs2: Don't merge in 1st refcount ops of reflink. · 7540c1a7
      Tao Ma 提交于
      Actually the whole reflink will touch refcount tree 2 times:
      1. It will add the clusters in the extent record to the tree if it
         isn't refcounted before.
      2. It will add 1 refcount to these clusters when it add these
         extent records to the tree.
      
      So actually we shouldn't do merge in the 1st operation since the 2nd
      one will soon be called and we may have to split it again. Do a merge
      first and split soon is a waste of time. So we only merge in the 2nd
      round. This is done by adding a new internal __ocfs2_increase_refcount
      and call it with "not-merge" for 1st refcount operation in reflink.
      
      This also has a side-effect that we don't need to worry too much about
      the metadata allocation in the 2nd round since it will only merge and
      no split will happen for those records.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      7540c1a7
    • T
      ocfs2: Add reflink support for xattr. · 2999d12f
      Tao Ma 提交于
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      2999d12f
    • T
      ocfs2: Call refcount tree remove process properly. · 8b2c0dba
      Tao Ma 提交于
      Now with xattr refcount support, we need to check whether
      we have xattr refcounted before we remove the refcount tree.
      
      Now the mechanism is:
      1) Check whether i_clusters == 0, if no, exit.
      2) check whether we have i_xattr_loc in dinode. if yes, exit.
      2) Check whether we have inline xattr stored outside, if yes, exit.
      4) Remove the tree.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      8b2c0dba
    • T
      ocfs2: Attach xattr clusters to refcount tree. · 0129241e
      Tao Ma 提交于
      In ocfs2, when xattr's value is larger than OCFS2_XATTR_INLINE_SIZE,
      it will be kept outside of the blocks we store xattr entry. And they
      are stored in a b-tree also. So this patch try to attach all these
      clusters to refcount tree also.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      0129241e
    • T
      ocfs2: Add CoW support for xattr. · 492a8a33
      Tao Ma 提交于
      In order to make 2 transcation(xattr and cow) independent with each other,
      we CoW the whole xattr out in case we are setting them.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      492a8a33
    • T
      ocfs2: Abstract duplicate clusters process in CoW. · 913580b4
      Tao Ma 提交于
      We currently use pagecache to duplicate clusters in CoW,
      but it isn't suitable for xattr case. So abstract it out
      so that the caller can decide which method it use.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      913580b4
    • T
      ocfs2: handle file attributes issue for reflink. · a9063ab9
      Tao Ma 提交于
      A reflink creates a snapshot of a file, that means the attributes
      must be identical except for three exceptions - nlink, ino, and ctime.
      
      As for time changes, Here is a brief description:
      
      1. Source file:
         1) atime: Ignore. Let the lazy atime code handle that.
         2) mtime: don't touch.
         3) ctime: If we change the tree (adding REFCOUNTED to at least one
                   extent), update it.
      2. Destination file:
         1) atime: ignore.
         2) mtime: we want it to appear identical to the source.
         3) ctime: update.
      
      The idea here is that an ls -l will show the same time for the
      src and target - it shows mtime.  Backup software like rsync and tar
      will treat the new file correctly too.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      a9063ab9
    • T
      ocfs2: Add normal functions for reflink a normal file's extents. · 110a045a
      Tao Ma 提交于
      2 major functions are added in this patch.
      
      ocfs2_attach_refcount_tree will create a new refcount tree to the
      old file if it doesn't have one and insert all the extent records
      to the tree if they are not refcounted.
      
      ocfs2_create_reflink_node will:
      1. set the refcount tree to the new file.
      2. call ocfs2_duplicate_extent_list which will iterate all the
         extents for the old file, insert it to the new file and increase
         the corresponding referennce count.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      110a045a
    • T
      ocfs2: CoW a reflinked cluster when it is truncated. · 37f8a2bf
      Tao Ma 提交于
      When we truncate a file to a specific size which resides in a reflinked
      cluster, we need to CoW it since ocfs2_zero_range_for_truncate will
      zero the space after the size(just another type of write).
      
      So we add a "max_cpos" in ocfs2_refcount_cow so that it will stop when
      it hit the max cluster offset.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      37f8a2bf
    • T
      ocfs2: CoW refcount tree improvement. · 6ae23c55
      Tao Ma 提交于
      During CoW, if the old extent record is refcounted, we allocate
      som new clusters and do CoW. Actually we can have some improvement
      here. If the old extent has refcount=1, that means now it is only
      used by this file. So we don't need to allocate new clusters, just
      remove the refcounted flag and it is OK. We also have to remove
      it from the refcount tree while not deleting it.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      6ae23c55