1. 04 4月, 2014 3 次提交
    • W
      ocfs2: pass "new" parameter to ocfs2_init_xattr_bucket · 9c339255
      Wengang Wang 提交于
      This patch fixes the following crash:
      
        kernel BUG at fs/ocfs2/uptodate.c:530!
        Modules linked in: ocfs2(F) ocfs2_dlmfs ocfs2_stack_o2cb ocfs2_dlm ocfs2_nodemanager ocfs2_stackglue configfs bridge xen_pciback xen_netback xen_blkback xen_gntalloc xen_gntdev xen_evtchn xenfs xen_privcmd sunrpc 8021q garp stp llc bonding be2iscsi iscsi_boot_sysfs bnx2i cnic uio cxgb4i cxgb4 cxgb3i libcxgbi cxgb3 mdio ib_iser rdma_cm ib_cm iw_cm ib_sa ib_mad ib_core ib_addr ipv6 iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi iTCO_wdt iTCO_vendor_support dcdbas coretemp freq_table mperf microcode pcspkr serio_raw bnx2 lpc_ich mfd_core i5k_amb i5000_edac edac_core e1000e sg shpchp ext4(F) jbd2(F) mbcache(F) dm_round_robin(F) sr_mod(F) cdrom(F) usb_storage(F) sd_mod(F) crc_t10dif(F) pata_acpi(F) ata_generic(F) ata_piix(F) mptsas(F) mptscsih(F) mptbase(F) scsi_transport_sas(F) radeon(F)
         ttm(F) drm_kms_helper(F) drm(F) hwmon(F) i2c_algo_bit(F) i2c_core(F) dm_multipath(F) dm_mirror(F) dm_region_hash(F) dm_log(F) dm_mod(F)
        CPU 5
        Pid: 21303, comm: xattr-test Tainted: GF       W    3.8.13-30.el6uek.x86_64 #2 Dell Inc. PowerEdge 1950/0M788G
        RIP: ocfs2_set_new_buffer_uptodate+0x51/0x60 [ocfs2]
        Process xattr-test (pid: 21303, threadinfo ffff880017aca000, task ffff880016a2c480)
        Call Trace:
          ocfs2_init_xattr_bucket+0x8a/0x120 [ocfs2]
          ocfs2_cp_xattr_bucket+0xbb/0x1b0 [ocfs2]
          ocfs2_extend_xattr_bucket+0x20a/0x2f0 [ocfs2]
          ocfs2_add_new_xattr_bucket+0x23e/0x4b0 [ocfs2]
          ocfs2_xattr_set_entry_index_block+0x13c/0x3d0 [ocfs2]
          ocfs2_xattr_block_set+0xf9/0x220 [ocfs2]
          __ocfs2_xattr_set_handle+0x118/0x710 [ocfs2]
          ocfs2_xattr_set+0x691/0x880 [ocfs2]
          ocfs2_xattr_user_set+0x46/0x50 [ocfs2]
          generic_setxattr+0x96/0xa0
          __vfs_setxattr_noperm+0x7b/0x170
          vfs_setxattr+0xbc/0xc0
          setxattr+0xde/0x230
          sys_fsetxattr+0xc6/0xf0
          system_call_fastpath+0x16/0x1b
        Code: 41 80 0c 24 01 48 89 df e8 7d f0 ff ff 4c 89 e6 48 89 df e8 a2 fe ff ff 48 89 df e8 3a f0 ff ff 48 8b 1c 24 4c 8b 64 24 08 c9 c3 <0f> 0b eb fe 90 90 90 90 90 90 90 90 90 90 90 55 48 89 e5 66 66
        RIP  ocfs2_set_new_buffer_uptodate+0x51/0x60 [ocfs2]
      
      It hit the BUG_ON() in ocfs2_set_new_buffer_uptodate():
      
          void ocfs2_set_new_buffer_uptodate(struct ocfs2_caching_info *ci,
                                             struct buffer_head *bh)
          {
                /* This should definitely *not* exist in our cache */
                if (ocfs2_buffer_cached(ci, bh))
                        printk(KERN_ERR "bh->b_blocknr: %lu @ %p\n", bh->b_blocknr, bh);
                BUG_ON(ocfs2_buffer_cached(ci, bh));
      
                set_buffer_uptodate(bh);
      
                ocfs2_metadata_cache_io_lock(ci);
                ocfs2_set_buffer_uptodate(ci, bh);
                ocfs2_metadata_cache_io_unlock(ci);
          }
      
      The problem here is:
      
      We cached a block, but the buffer_head got reused.  When we are to pick
      up this block again, a new buffer_head created with UPTODATE flag
      cleared.  ocfs2_buffer_uptodate() returned false since no UPTODATE is
      set on the buffer_head.  so we set this block to cache as a NEW block,
      then it failed at asserting block is not in cache.
      
      The fix is to add a new parameter indicating the bucket is a new
      allocated or not to ocfs2_init_xattr_bucket().
      ocfs2_init_xattr_bucket() assert block not cached accordingly.
      Signed-off-by: NWengang Wang <wen.gang.wang@oracle.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Reviewed-by: NMark Fasheh <mfasheh@suse.de>
      Cc: Joe Jin <joe.jin@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9c339255
    • D
      ocfs2: call ocfs2_update_inode_fsync_trans when updating any inode · 6fdb702d
      Darrick J. Wong 提交于
      Ensure that ocfs2_update_inode_fsync_trans() is called any time we touch
      an inode in a given transaction.  This is a follow-on to the previous
      patch to reduce lock contention and deadlocking during an fsync
      operation.
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Cc: Mark Fasheh <mfasheh@suse.de>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Wengang <wen.gang.wang@oracle.com>
      Cc: Greg Marsden <greg.marsden@oracle.com>
      Cc: Srinivas Eeda <srinivas.eeda@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6fdb702d
    • T
      ocfs2: allow for more than one data extent when creating xattr · 3ed2be71
      Tariq Saeed 提交于
      Orabug: 18108070
      
      ocfs2_xattr_extend_allocation() hits panic when creating xattr during
      data extent alloc phase.  The problem occurs if due to local alloc
      fragmentation, clusters are spread over multiple extents.  In this case
      ocfs2_add_clusters_in_btree() finds no space to store more than one
      extent record and therefore fails returning RESTART_META.  The situation
      is anticipated for xattr update case but not xattr create case.  This
      fix simply ports that code to create case.
      Signed-off-by: NTariq Saeed <tariq.x.saeed@oracle.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3ed2be71
  2. 26 1月, 2014 1 次提交
  3. 13 11月, 2013 3 次提交
  4. 12 9月, 2013 3 次提交
  5. 04 7月, 2013 2 次提交
    • J
      ocfs2: xattr: fix inlined xattr reflink · ef962df0
      Junxiao Bi 提交于
      Inlined xattr shared free space of inode block with inlined data or data
      extent record, so the size of the later two should be adjusted when
      inlined xattr is enabled.  See ocfs2_xattr_ibody_init().  But this isn't
      done well when reflink.  For inode with inlined data, its max inlined
      data size is adjusted in ocfs2_duplicate_inline_data(), no problem.  But
      for inode with data extent record, its record count isn't adjusted.  Fix
      it, or data extent record and inlined xattr may overwrite each other,
      then cause data corruption or xattr failure.
      
      One panic caused by this bug in our test environment is the following:
      
        kernel BUG at fs/ocfs2/xattr.c:1435!
        invalid opcode: 0000 [#1] SMP
        Pid: 10871, comm: multi_reflink_t Not tainted 2.6.39-300.17.1.el5uek #1
        RIP: ocfs2_xa_offset_pointer+0x17/0x20 [ocfs2]
        RSP: e02b:ffff88007a587948  EFLAGS: 00010283
        RAX: 0000000000000000 RBX: 0000000000000010 RCX: 00000000000051e4
        RDX: ffff880057092060 RSI: 0000000000000f80 RDI: ffff88007a587a68
        RBP: ffff88007a587948 R08: 00000000000062f4 R09: 0000000000000000
        R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000010
        R13: ffff88007a587a68 R14: 0000000000000001 R15: ffff88007a587c68
        FS:  00007fccff7f06e0(0000) GS:ffff88007fc00000(0000) knlGS:0000000000000000
        CS:  e033 DS: 0000 ES: 0000 CR0: 000000008005003b
        CR2: 00000000015cf000 CR3: 000000007aa76000 CR4: 0000000000000660
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
        Process multi_reflink_t
        Call Trace:
          ocfs2_xa_reuse_entry+0x60/0x280 [ocfs2]
          ocfs2_xa_prepare_entry+0x17e/0x2a0 [ocfs2]
          ocfs2_xa_set+0xcc/0x250 [ocfs2]
          ocfs2_xattr_ibody_set+0x98/0x230 [ocfs2]
          __ocfs2_xattr_set_handle+0x4f/0x700 [ocfs2]
          ocfs2_xattr_set+0x6c6/0x890 [ocfs2]
          ocfs2_xattr_user_set+0x46/0x50 [ocfs2]
          generic_setxattr+0x70/0x90
          __vfs_setxattr_noperm+0x80/0x1a0
          vfs_setxattr+0xa9/0xb0
          setxattr+0xc3/0x120
          sys_fsetxattr+0xa8/0xd0
          system_call_fastpath+0x16/0x1b
      Signed-off-by: NJunxiao Bi <junxiao.bi@oracle.com>
      Reviewed-by: NJie Liu <jeff.liu@oracle.com>
      Acked-by: NJoel Becker <jlbec@evilplan.org>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Sunil Mushran <sunil.mushran@gmail.com>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ef962df0
    • J
      ocfs2: xattr: remove useless free space checking · b30f14c4
      Junxiao Bi 提交于
      Free space checking will be done in ocfs2_xattr_ibody_init().  So remove
      here.
      
      [akpm@linux-foundation.org: remove unused local]
      Signed-off-by: NJunxiao Bi <junxiao.bi@oracle.com>
      Reviewed-by: NJie Liu <jeff.liu@oracle.com>
      Acked-by: NJoel Becker <jlbec@evilplan.org>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b30f14c4
  6. 28 2月, 2013 1 次提交
    • J
      ocfs2: fix ocfs2_init_security_and_acl() to initialize acl correctly · 32918dd9
      Jeff Liu 提交于
      We need to re-initialize the security for a new reflinked inode with its
      parent dirs if it isn't specified to be preserved for ocfs2_reflink().
      However, the code logic is broken at ocfs2_init_security_and_acl()
      although ocfs2_init_security_get() succeed.  As a result,
      ocfs2_acl_init() does not involked and therefore the default ACL of
      parent dir was missing on the new inode.
      
      Note this was introduced by 9d8f13ba ("security: new
      security_inode_init_security API adds function callback")
      
      To reproduce:
      
          set default ACL for the parent dir(ocfs2 in this case):
          $ setfacl -m default:user:jeff:rwx ../ocfs2/
          $ getfacl ../ocfs2/
          # file: ../ocfs2/
          # owner: jeff
          # group: jeff
          user::rwx
          group::r-x
          other::r-x
          default:user::rwx
          default:user:jeff:rwx
          default:group::r-x
          default:mask::rwx
          default:other::r-x
      
          $ touch a
          $ getfacl a
          # file: a
          # owner: jeff
          # group: jeff
          user::rw-
          group::rw-
          other::r--
      
      Before patching, create reflink file b from a, the user
      default ACL entry(user:jeff:rwx)was missing:
      
          $ ./ocfs2_reflink a b
          $ getfacl b
          # file: b
          # owner: jeff
          # group: jeff
          user::rw-
          group::rw-
          other::r--
      
      In this case, the end user can also observed an error message at syslog:
      
        (ocfs2_reflink,3229,2):ocfs2_init_security_and_acl:7193 ERROR: status = 0
      
      After applying this patch, create reflink file c from a:
      
          $ ./ocfs2_reflink a c
          $ getfacl c
          # file: c
          # owner: jeff
          # group: jeff
          user::rw-
          user:jeff:rwx			#effective:rw-
          group::r-x			#effective:r--
          mask::rw-
          other::r--
      
      Test program:
      /* Usage: reflink <source> <dest> */
      #include <stdio.h>
      #include <stdint.h>
      #include <stdbool.h>
      #include <string.h>
      #include <errno.h>
      #include <sys/types.h>
      #include <sys/stat.h>
      #include <fcntl.h>
      #include <sys/ioctl.h>
      
      static int
      reflink_file(char const *src_name, char const *dst_name,
      	     bool preserve_attrs)
      {
      	int fd;
      
      #ifndef REFLINK_ATTR_NONE
      #  define REFLINK_ATTR_NONE 0
      #endif
      #ifndef REFLINK_ATTR_PRESERVE
      #  define REFLINK_ATTR_PRESERVE 1
      #endif
      #ifndef OCFS2_IOC_REFLINK
      	struct reflink_arguments {
      		uint64_t old_path;
      		uint64_t new_path;
      		uint64_t preserve;
      	};
      
      #  define OCFS2_IOC_REFLINK _IOW ('o', 4, struct reflink_arguments)
      #endif
      	struct reflink_arguments args = {
      		.old_path = (unsigned long) src_name,
      		.new_path = (unsigned long) dst_name,
      		.preserve = preserve_attrs ? REFLINK_ATTR_PRESERVE :
      					     REFLINK_ATTR_NONE,
      	};
      
      	fd = open(src_name, O_RDONLY);
      	if (fd < 0) {
      		fprintf(stderr, "Failed to open %s: %s\n",
      			src_name, strerror(errno));
      		return -1;
      	}
      
      	if (ioctl(fd, OCFS2_IOC_REFLINK, &args) < 0) {
      		fprintf(stderr, "Failed to reflink %s to %s: %s\n",
      			src_name, dst_name, strerror(errno));
      		return -1;
      	}
      }
      
      int
      main(int argc, char *argv[])
      {
      	if (argc != 3) {
      		fprintf(stdout, "Usage: %s source dest\n", argv[0]);
      		return 1;
      	}
      
      	return reflink_file(argv[1], argv[2], 0);
      }
      Signed-off-by: NJie Liu <jeff.liu@oracle.com>
      Reviewed-by: NTao Ma <boyu.mt@taobao.com>
      Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      32918dd9
  7. 04 1月, 2012 1 次提交
  8. 17 11月, 2011 1 次提交
  9. 19 7月, 2011 1 次提交
    • M
      security: new security_inode_init_security API adds function callback · 9d8f13ba
      Mimi Zohar 提交于
      This patch changes the security_inode_init_security API by adding a
      filesystem specific callback to write security extended attributes.
      This change is in preparation for supporting the initialization of
      multiple LSM xattrs and the EVM xattr.  Initially the callback function
      walks an array of xattrs, writing each xattr separately, but could be
      optimized to write multiple xattrs at once.
      
      For existing security_inode_init_security() calls, which have not yet
      been converted to use the new callback function, such as those in
      reiserfs and ocfs2, this patch defines security_old_inode_init_security().
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      9d8f13ba
  10. 31 3月, 2011 1 次提交
  11. 23 2月, 2011 1 次提交
  12. 07 3月, 2011 1 次提交
    • T
      ocfs2: Remove EXIT from masklog. · c1e8d35e
      Tao Ma 提交于
      mlog_exit is used to record the exit status of a function.
      But because it is added in so many functions, if we enable it,
      the system logs get filled up quickly and cause too much I/O.
      So actually no one can open it for a production system or even
      for a test.
      
      This patch just try to remove it or change it. So:
      1. if all the error paths already use mlog_errno, it is just removed.
         Otherwise, it will be replaced by mlog_errno.
      2. if it is used to print some return value, it is replaced with
         mlog(0,...).
      mlog_exit_ptr is changed to mlog(0.
      All those mlog(0,...) will be replaced with trace events later.
      Signed-off-by: NTao Ma <boyu.mt@taobao.com>
      c1e8d35e
  13. 21 2月, 2011 1 次提交
    • T
      ocfs2: Remove ENTRY from masklog. · ef6b689b
      Tao Ma 提交于
      ENTRY is used to record the entry of a function.
      But because it is added in so many functions, if we enable it,
      the system logs get filled up quickly and cause too much I/O.
      So actually no one can open it for a production system or even
      for a test.
      
      So for mlog_entry_void, we just remove it.
      for mlog_entry(...), we replace it with mlog(0,...), and they
      will be replace by trace event later.
      Signed-off-by: NTao Ma <boyu.mt@taobao.com>
      ef6b689b
  14. 02 2月, 2011 1 次提交
    • E
      fs/vfs/security: pass last path component to LSM on inode creation · 2a7dba39
      Eric Paris 提交于
      SELinux would like to implement a new labeling behavior of newly created
      inodes.  We currently label new inodes based on the parent and the creating
      process.  This new behavior would also take into account the name of the
      new object when deciding the new label.  This is not the (supposed) full path,
      just the last component of the path.
      
      This is very useful because creating /etc/shadow is different than creating
      /etc/passwd but the kernel hooks are unable to differentiate these
      operations.  We currently require that userspace realize it is doing some
      difficult operation like that and than userspace jumps through SELinux hoops
      to get things set up correctly.  This patch does not implement new
      behavior, that is obviously contained in a seperate SELinux patch, but it
      does pass the needed name down to the correct LSM hook.  If no such name
      exists it is fine to pass NULL.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      2a7dba39
  15. 16 10月, 2010 1 次提交
  16. 11 9月, 2010 1 次提交
    • T
      ocfs2/lockdep: Move ip_xattr_sem out of ocfs2_xattr_get_nolock. · 5e64b0d9
      Tao Ma 提交于
      As the name shows, we shouldn't have any lock in
      ocfs2_xattr_get_nolock. so lift ip_xattr_sem to the caller.
      This should be safe for us since the only 2 callers are:
      1. ocfs2_xattr_get which will lock the resources.
      2. ocfs2_mknod which don't need this locking.
      
      And this also resolves the following lockdep warning.
      
      =======================================================
      [ INFO: possible circular locking dependency detected ]
      2.6.35+ #5
      -------------------------------------------------------
      reflink/30027 is trying to acquire lock:
       (&oi->ip_alloc_sem){+.+.+.}, at: [<ffffffffa0673b67>] ocfs2_reflink_ioctl+0x69a/0x1226 [ocfs2]
      
      but task is already holding lock:
       (&oi->ip_xattr_sem){++++..}, at: [<ffffffffa0673b58>] ocfs2_reflink_ioctl+0x68b/0x1226 [ocfs2]
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #3 (&oi->ip_xattr_sem){++++..}:
             [<ffffffff82064d6d>] __lock_acquire+0x79a/0x7f1
             [<ffffffff82065a81>] lock_acquire+0xc6/0xed
             [<ffffffff82339650>] down_read+0x34/0x47
             [<ffffffffa0691cb8>] ocfs2_xattr_get_nolock+0xa0/0x4e6 [ocfs2]
             [<ffffffffa069d64f>] ocfs2_get_acl_nolock+0x5c/0x132 [ocfs2]
             [<ffffffffa069d9c7>] ocfs2_init_acl+0x60/0x243 [ocfs2]
             [<ffffffffa066499d>] ocfs2_mknod+0xae8/0xfea [ocfs2]
             [<ffffffffa0665041>] ocfs2_create+0x9d/0x105 [ocfs2]
             [<ffffffff820e1c83>] vfs_create+0x9b/0xf4
             [<ffffffff820e20bb>] do_last+0x2fd/0x5be
             [<ffffffff820e31c0>] do_filp_open+0x1fb/0x572
             [<ffffffff820d6cf6>] do_sys_open+0x5a/0xe7
             [<ffffffff820d6dac>] sys_open+0x1b/0x1d
             [<ffffffff8200296b>] system_call_fastpath+0x16/0x1b
      
      -> #2 (jbd2_handle){+.+...}:
             [<ffffffff82064d6d>] __lock_acquire+0x79a/0x7f1
             [<ffffffff82065a81>] lock_acquire+0xc6/0xed
             [<ffffffffa0604ff8>] start_this_handle+0x4a3/0x4bc [jbd2]
             [<ffffffffa06051d6>] jbd2__journal_start+0xba/0xee [jbd2]
             [<ffffffffa0605218>] jbd2_journal_start+0xe/0x10 [jbd2]
             [<ffffffffa065ca34>] ocfs2_start_trans+0xb7/0x19b [ocfs2]
             [<ffffffffa06645f3>] ocfs2_mknod+0x73e/0xfea [ocfs2]
             [<ffffffffa0665041>] ocfs2_create+0x9d/0x105 [ocfs2]
             [<ffffffff820e1c83>] vfs_create+0x9b/0xf4
             [<ffffffff820e20bb>] do_last+0x2fd/0x5be
             [<ffffffff820e31c0>] do_filp_open+0x1fb/0x572
             [<ffffffff820d6cf6>] do_sys_open+0x5a/0xe7
             [<ffffffff820d6dac>] sys_open+0x1b/0x1d
             [<ffffffff8200296b>] system_call_fastpath+0x16/0x1b
      
      -> #1 (&journal->j_trans_barrier){.+.+..}:
             [<ffffffff82064d6d>] __lock_acquire+0x79a/0x7f1
             [<ffffffff82064fa9>] lock_release_non_nested+0x1e5/0x24b
             [<ffffffff82065999>] lock_release+0x158/0x17a
             [<ffffffff823389f6>] __mutex_unlock_slowpath+0xbf/0x11b
             [<ffffffff82338a5b>] mutex_unlock+0x9/0xb
             [<ffffffffa0679673>] ocfs2_free_ac_resource+0x31/0x67 [ocfs2]
             [<ffffffffa067c6bc>] ocfs2_free_alloc_context+0x11/0x1d [ocfs2]
             [<ffffffffa0633de0>] ocfs2_write_begin_nolock+0x141e/0x159b [ocfs2]
             [<ffffffffa0635523>] ocfs2_write_begin+0x11e/0x1e7 [ocfs2]
             [<ffffffff820a1297>] generic_file_buffered_write+0x10c/0x210
             [<ffffffffa0653624>] ocfs2_file_aio_write+0x4cc/0x6d3 [ocfs2]
             [<ffffffff820d822d>] do_sync_write+0xc2/0x106
             [<ffffffff820d897b>] vfs_write+0xae/0x131
             [<ffffffff820d8e55>] sys_write+0x47/0x6f
             [<ffffffff8200296b>] system_call_fastpath+0x16/0x1b
      
      -> #0 (&oi->ip_alloc_sem){+.+.+.}:
             [<ffffffff82063f92>] validate_chain+0x727/0xd68
             [<ffffffff82064d6d>] __lock_acquire+0x79a/0x7f1
             [<ffffffff82065a81>] lock_acquire+0xc6/0xed
             [<ffffffff82339694>] down_write+0x31/0x52
             [<ffffffffa0673b67>] ocfs2_reflink_ioctl+0x69a/0x1226 [ocfs2]
             [<ffffffffa06599f6>] ocfs2_ioctl+0x61a/0x656 [ocfs2]
             [<ffffffff820e53ac>] vfs_ioctl+0x2a/0x9d
             [<ffffffff820e5903>] do_vfs_ioctl+0x45d/0x4ae
             [<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>
      5e64b0d9
  17. 13 7月, 2010 2 次提交
  18. 22 5月, 2010 1 次提交
  19. 19 5月, 2010 2 次提交
    • T
      ocfs2: Don't retry xattr set in case value extension fails. · 5f5261ac
      Tao Ma 提交于
      In normal xattr set, the set sequence is inode, xattr block
      and finally xattr bucket if we meet with a ENOSPC. But there
      is a corner case.
      So consider we will set a xattr whose value will be stored in
      a cluster, and there is no xattr block by now. So we will
      reserve 1 xattr block and 1 cluster for setting it. Now if we
      fail in value extension(in case the volume is almost full and
      we can't allocate the cluster because the check in
      ocfs2_test_bg_bit_allocatable), ENOSPC will be returned. So
      we will try to create a bucket(this time there is a chance that
      the reserved cluster will be used), and when we try value extension
      again, kernel bug happens. We did meet with it. Check the bug below.
      http://oss.oracle.com/bugzilla/show_bug.cgi?id=1251
      
      This patch just try to avoid this by adding a set_abort in
      ocfs2_xattr_set_ctxt, so in case ENOSPC happens in value extension,
      we will check whether it is caused by the real ENOSPC or just the
      full of inode or xattr block. If it is the first case, we set set_abort
      so that we don't try any further. we are safe to exit directly here
      ince it is really ENOSPC.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      5f5261ac
    • T
      ocfs2: Reset xattr value size after xa_cleanup_value_truncate(). · d5a7df06
      Tao Ma 提交于
      In ocfs2_prepare_xattr_entry, if we fail to grow an existing value,
      xa_cleanup_value_truncate() will leave the old entry in place.  Thus, we
      reset its value size.  However, if we were allocating a new value, we
      must not reset the value size or we will BUG().  This resolves
      oss.oracle.com bug 1247.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      d5a7df06
  20. 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
  21. 20 3月, 2010 2 次提交
    • T
      ocfs2: Init meta_ac properly in ocfs2_create_empty_xattr_block. · b2317968
      Tao Ma 提交于
      You can't store a pointer that you haven't filled in yet and expect it
      to work.
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      b2317968
    • T
      ocfs2: Fix the update of name_offset when removing xattrs · dfe4d3d6
      Tao Ma 提交于
      When replacing a xattr's value, in some case we wipe its name/value
      first and then re-add it. The wipe is done by
      ocfs2_xa_block_wipe_namevalue() when the xattr is in the inode or
      block. We currently adjust name_offset for all the entries which have
      (offset < name_offset). This does not adjust the entrie we're replacing.
      Since we are replacing the entry, we don't adjust the total entry count.
      When we calculate a new namevalue location, we trust the entries
      now-wrong offset in ocfs2_xa_get_free_start().  The solution is to
      also adjust the name_offset for the replaced entry, allowing
      ocfs2_xa_get_free_start() to calculate the new namevalue location
      correctly.
      
      The following script can trigger a kernel panic easily.
      
      echo 'y'|mkfs.ocfs2 --fs-features=local,xattr -b 4K $DEVICE
      mount -t ocfs2 $DEVICE $MNT_DIR
      FILE=$MNT_DIR/$RANDOM
      for((i=0;i<76;i++))
      do
      string_76="a$string_76"
      done
      string_78="aa$string_76"
      string_82="aaaa$string_78"
      
      touch $FILE
      setfattr -n 'user.test1234567890' -v $string_76 $FILE
      setfattr -n 'user.test1234567890' -v $string_78 $FILE
      setfattr -n 'user.test1234567890' -v $string_82 $FILE
      Signed-off-by: NTao Ma <tao.ma@oracle.com>
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      dfe4d3d6
  22. 22 3月, 2010 1 次提交
  23. 26 3月, 2010 1 次提交
  24. 06 5月, 2010 1 次提交
  25. 27 2月, 2010 5 次提交
    • J
      ocfs2: Handle errors while setting external xattr values. · 399ff3a7
      Joel Becker 提交于
      ocfs2 can store extended attribute values as large as a single file.  It
      does this using a standard ocfs2 btree for the large value.  However,
      the previous code did not handle all error cases cleanly.
      
      There are multiple problems to have.
      
      1) We have trouble allocating space for a new xattr.  This leaves us
         with an empty xattr.
      2) We overwrote an existing local xattr with a value root, and now we
         have an error allocating the storage.  This leaves us an empty xattr.
         where there used to be a value.  The value is lost.
      3) We have trouble truncating a reused value.  This leaves us with the
         original entry pointing to the truncated original value.  The value
         is lost.
      4) We have trouble extending the storage on a reused value.  This leaves
         us with the original value safely in place, but with more storage
         allocated when needed.
      
      This doesn't consider storing local xattrs (values that don't require a
      btree).  Those only fail when the journal fails.
      
      Case (1) is easy.  We just remove the xattr we added.  We leak the
      storage because we can't safely remove it, but otherwise everything is
      happy.  We'll print a warning about the leak.
      
      Case (4) is easy.  We still have the original value in place.  We can
      just leave the extra storage attached to this xattr.  We return the
      error, but the old value is untouched.  We print a warning about the
      storage.
      
      Case (2) and (3) are hard because we've lost the original values.  In
      the old code, we ended up with values that could be partially read.
      That's not good.  Instead, we just wipe the xattr entry and leak the
      storage.  It stinks that the original value is lost, but now there isn't
      a partial value to be read.  We'll print a big fat warning.
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      399ff3a7
    • J
      ocfs2: Set inline xattr entries with ocfs2_xa_set() · 139fface
      Joel Becker 提交于
      ocfs2_xattr_ibody_set() is the only remaining user of
      ocfs2_xattr_set_entry().  ocfs2_xattr_set_entry() actually does two
      things: it calls ocfs2_xa_set(), and it initializes the inline xattrs.
      Initializing the inline space really belongs in its own call.
      
      We lift the initialization to ocfs2_xattr_ibody_init(), called from
      ocfs2_xattr_ibody_set() only when necessary.  Now
      ocfs2_xattr_ibody_set() can call ocfs2_xa_set() directly.
      ocfs2_xattr_set_entry() goes away.
      
      Another nice fact is that ocfs2_init_dinode_xa_loc() can trust
      i_xattr_inline_size.
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      139fface
    • J
      ocfs2: Set xattr block entries with ocfs2_xa_set() · d3981544
      Joel Becker 提交于
      ocfs2_xattr_block_set() calls into ocfs2_xattr_set_entry() with just the
      HAS_XATTR flag.  Most of the machinery of ocfs2_xattr_set_entry() is
      skipped.  All that really happens other than the call to ocfs2_xa_set()
      is making sure the HAS_XATTR flag is set on the inode.
      
      But HAS_XATTR should be set when we also set di->i_xattr_loc.  And
      that's done in ocfs2_create_xattr_block().  So let's move it there, and
      then ocfs2_xattr_block_set() can just call ocfs2_xa_set().
      
      While we're there, ocfs2_create_xattr_block() can take the set_ctxt for
      a smaller argument list.  It also learns to set HAS_XATTR_FL, because it
      knows for sure.  ocfs2_create_empty_xatttr_block() in the reflink path
      fakes a set_ctxt to call ocfs2_create_xattr_block().
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      d3981544
    • J
      ocfs2: Let ocfs2_xa_prepare_entry() do space checks. · c5d95df5
      Joel Becker 提交于
      ocfs2_xattr_set_in_bucket() doesn't need to do its own hacky space
      checking.  Let's let ocfs2_xa_prepare_entry() (via ocfs2_xa_set()) do
      the more accurate work.  Whenever it doesn't have space,
      ocfs2_xattr_set_in_bucket() can try to get more space.
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      c5d95df5
    • J
      ocfs2: Gell into ocfs2_xa_set() · bca5e9bd
      Joel Becker 提交于
      ocfs2_xa_set() wraps the ocfs2_xa_prepare_entry()/ocfs2_xa_store_value()
      logic.  Both callers can now use the same routine.  ocfs2_xa_remove()
      moves directly into ocfs2_xa_set().
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      bca5e9bd