1. 23 2月, 2015 1 次提交
    • D
      VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry) · e36cb0b8
      David Howells 提交于
      Convert the following where appropriate:
      
       (1) S_ISLNK(dentry->d_inode) to d_is_symlink(dentry).
      
       (2) S_ISREG(dentry->d_inode) to d_is_reg(dentry).
      
       (3) S_ISDIR(dentry->d_inode) to d_is_dir(dentry).  This is actually more
           complicated than it appears as some calls should be converted to
           d_can_lookup() instead.  The difference is whether the directory in
           question is a real dir with a ->lookup op or whether it's a fake dir with
           a ->d_automount op.
      
      In some circumstances, we can subsume checks for dentry->d_inode not being
      NULL into this, provided we the code isn't in a filesystem that expects
      d_inode to be NULL if the dirent really *is* negative (ie. if we're going to
      use d_inode() rather than d_backing_inode() to get the inode pointer).
      
      Note that the dentry type field may be set to something other than
      DCACHE_MISS_TYPE when d_inode is NULL in the case of unionmount, where the VFS
      manages the fall-through from a negative dentry to a lower layer.  In such a
      case, the dentry type of the negative union dentry is set to the same as the
      type of the lower dentry.
      
      However, if you know d_inode is not NULL at the call site, then you can use
      the d_is_xxx() functions even in a filesystem.
      
      There is one further complication: a 0,0 chardev dentry may be labelled
      DCACHE_WHITEOUT_TYPE rather than DCACHE_SPECIAL_TYPE.  Strictly, this was
      intended for special directory entry types that don't have attached inodes.
      
      The following perl+coccinelle script was used:
      
      use strict;
      
      my @callers;
      open($fd, 'git grep -l \'S_IS[A-Z].*->d_inode\' |') ||
          die "Can't grep for S_ISDIR and co. callers";
      @callers = <$fd>;
      close($fd);
      unless (@callers) {
          print "No matches\n";
          exit(0);
      }
      
      my @cocci = (
          '@@',
          'expression E;',
          '@@',
          '',
          '- S_ISLNK(E->d_inode->i_mode)',
          '+ d_is_symlink(E)',
          '',
          '@@',
          'expression E;',
          '@@',
          '',
          '- S_ISDIR(E->d_inode->i_mode)',
          '+ d_is_dir(E)',
          '',
          '@@',
          'expression E;',
          '@@',
          '',
          '- S_ISREG(E->d_inode->i_mode)',
          '+ d_is_reg(E)' );
      
      my $coccifile = "tmp.sp.cocci";
      open($fd, ">$coccifile") || die $coccifile;
      print($fd "$_\n") || die $coccifile foreach (@cocci);
      close($fd);
      
      foreach my $file (@callers) {
          chomp $file;
          print "Processing ", $file, "\n";
          system("spatch", "--sp-file", $coccifile, $file, "--in-place", "--no-show-diff") == 0 ||
      	die "spatch failed";
      }
      
      [AV: overlayfs parts skipped]
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      e36cb0b8
  2. 21 1月, 2015 1 次提交
  3. 18 12月, 2014 4 次提交
  4. 20 11月, 2014 2 次提交
  5. 15 10月, 2014 3 次提交
  6. 28 7月, 2014 1 次提交
  7. 21 7月, 2014 1 次提交
  8. 08 7月, 2014 2 次提交
  9. 12 6月, 2014 1 次提交
  10. 07 5月, 2014 9 次提交
  11. 12 4月, 2014 2 次提交
  12. 05 4月, 2014 1 次提交
  13. 03 4月, 2014 2 次提交
  14. 02 4月, 2014 2 次提交
  15. 18 2月, 2014 1 次提交
  16. 29 1月, 2014 1 次提交
  17. 14 12月, 2013 3 次提交
  18. 07 9月, 2013 1 次提交
  19. 28 8月, 2013 2 次提交
    • M
      ceph: allow sync_read/write return partial successed size of read/write. · ee7289bf
      majianpeng 提交于
      For sync_read/write, it may do multi stripe operations.If one of those
      met erro, we return the former successed size rather than a error value.
      There is a exception for write-operation met -EOLDSNAPC.If this occur,we
      retry the whole write again.
      Signed-off-by: NJianpeng Ma <majianpeng@gmail.com>
      ee7289bf
    • M
      ceph: fix bugs about handling short-read for sync read mode. · 02ae66d8
      majianpeng 提交于
      cephfs . show_layout
      >layyout.data_pool:     0
      >layout.object_size:   4194304
      >layout.stripe_unit:   4194304
      >layout.stripe_count:  1
      
      TestA:
      >dd if=/dev/urandom of=test bs=1M count=2 oflag=direct
      >dd if=/dev/urandom of=test bs=1M count=2 seek=4  oflag=direct
      >dd if=test of=/dev/null bs=6M count=1 iflag=direct
      The messages from func striped_read are:
      ceph:           file.c:350  : striped_read 0~6291456 (read 0) got 2097152 HITSTRIPE SHORT
      ceph:           file.c:350  : striped_read 2097152~4194304 (read 2097152) got 0 HITSTRIPE SHORT
      ceph:           file.c:381  : zero tail 4194304
      ceph:           file.c:390  : striped_read returns 6291456
      The hole of file is from 2M--4M.But actualy it zero the last 4M include
      the last 2M area which isn't a hole.
      Using this patch, the messages are:
      ceph:           file.c:350  : striped_read 0~6291456 (read 0) got 2097152 HITSTRIPE SHORT
      ceph:           file.c:358  :  zero gap 2097152 to 4194304
      ceph:           file.c:350  : striped_read 4194304~2097152 (read 4194304) got 2097152
      ceph:           file.c:384  : striped_read returns 6291456
      
      TestB:
      >echo majianpeng > test
      >dd if=test of=/dev/null bs=2M count=1 iflag=direct
      The messages are:
      ceph:           file.c:350  : striped_read 0~6291456 (read 0) got 11 HITSTRIPE SHORT
      ceph:           file.c:350  : striped_read 11~6291445 (read 11) got 0 HITSTRIPE SHORT
      ceph:           file.c:390  : striped_read returns 11
      For this case,it did once more striped_read.It's no meaningless.
      Using this patch, the message are:
      ceph:           file.c:350  : striped_read 0~6291456 (read 0) got 11 HITSTRIPE SHORT
      ceph:           file.c:384  : striped_read returns 11
      
      Big thanks to Yan Zheng for the patch.
      Reviewed-by: NYan, Zheng <zheng.z.yan@intel.com>
      Signed-off-by: NJianpeng Ma <majianpeng@gmail.com>
      02ae66d8