Advertisement
Guest User

Ext4 data races - generic_fillattr

a guest
Apr 8th, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 18.91 KB | None | 0 0
  1. ====================================================================================================================================================================================
  2. Variable: inode->i_blocks   Addresses: c10aa04b c10aa891 c10a9f72
  3. c10a9f72 __inode_sub_bytes /linux-3.13.5/fs/stat.c:471
  4. c10aa891 __inode_add_bytes /linux-3.13.5/fs/stat.c:451
  5. c10aa04b generic_fillattr /linux-3.13.5/fs/stat.c:35
  6.  
  7. c10aa04b <-> c10a9f72
  8. c10aa04b <-> c10aa891
  9. c10aa04b <-> c10a9f72
  10.  
  11. /linux-3.13.5/fs/stat.c:471
  12.        461  {
  13.        462      spin_lock(&inode->i_lock);
  14.        463      __inode_add_bytes(inode, bytes);
  15.        464      spin_unlock(&inode->i_lock);
  16.        465  }
  17.        466 
  18.        467  EXPORT_SYMBOL(inode_add_bytes);
  19.        468 
  20.        469  void __inode_sub_bytes(struct inode *inode, loff_t bytes)
  21.        470  {
  22. ==>    471      inode->i_blocks -= bytes >> 9;      
  23.        472      bytes &= 511;
  24.        473      if (inode->i_bytes < bytes) {
  25.        474          inode->i_blocks--;
  26.        475          inode->i_bytes += 512;
  27.        476      }
  28.        477      inode->i_bytes -= bytes;
  29.        478  }
  30.        479 
  31.        480  EXPORT_SYMBOL(__inode_sub_bytes);
  32.        481 
  33.  
  34. /linux-3.13.5/fs/stat.c:451
  35.        441      error = vfs_fstatat(dfd, filename, &stat, flag);
  36.        442      if (error)
  37.        443          return error;
  38.        444      return cp_new_stat64(&stat, statbuf);
  39.        445  }
  40.        446  #endif /* __ARCH_WANT_STAT64 || __ARCH_WANT_COMPAT_STAT64 */
  41.        447 
  42.        448  /* Caller is here responsible for sufficient locking (ie. inode->i_lock) */
  43.        449  void __inode_add_bytes(struct inode *inode, loff_t bytes)
  44.        450  {
  45. ==>    451      inode->i_blocks += bytes >> 9;      
  46.        452      bytes &= 511;
  47.        453      inode->i_bytes += bytes;
  48.        454      if (inode->i_bytes >= 512) {
  49.        455          inode->i_blocks++;
  50.        456          inode->i_bytes -= 512;
  51.        457      }
  52.        458  }
  53.        459 
  54.        460  void inode_add_bytes(struct inode *inode, loff_t bytes)
  55.        461  {
  56.  
  57. /linux-3.13.5/fs/stat.c:35
  58.         25      stat->mode = inode->i_mode;
  59.         26      stat->nlink = inode->i_nlink;
  60.         27      stat->uid = inode->i_uid;
  61.         28      stat->gid = inode->i_gid;
  62.         29      stat->rdev = inode->i_rdev;
  63.         30      stat->size = i_size_read(inode);
  64.         31      stat->atime = inode->i_atime;
  65.         32      stat->mtime = inode->i_mtime;
  66.         33      stat->ctime = inode->i_ctime;
  67.         34      stat->blksize = (1 << inode->i_blkbits);
  68. ==>     35      stat->blocks = inode->i_blocks;      
  69.         36  }
  70.         37 
  71.         38  EXPORT_SYMBOL(generic_fillattr);
  72.         39 
  73.         40  /**
  74.         41   * vfs_getattr_nosec - getattr without security checks
  75.         42   * @path: file to get attributes from
  76.         43   * @stat: structure to return attributes in
  77.         44   *
  78.         45   * Get attributes without calling security_inode_getattr.
  79.  
  80.  
  81. ====================================================================================================================================================================================
  82. Variable: inode->i_ctime    Addresses: c10aa032 c110b231
  83. c10aa032 generic_fillattr /linux-3.13.5/fs/stat.c:33
  84. c110b231 ext4_current_time /linux-3.13.5/fs/ext4/inode.c:3769
  85.  
  86. c10aa032 <-> c110b231
  87. c10aa032 <-> c110b231
  88.  
  89. /linux-3.13.5/fs/stat.c:33
  90.         23      stat->dev = inode->i_sb->s_dev;
  91.         24      stat->ino = inode->i_ino;
  92.         25      stat->mode = inode->i_mode;
  93.         26      stat->nlink = inode->i_nlink;
  94.         27      stat->uid = inode->i_uid;
  95.         28      stat->gid = inode->i_gid;
  96.         29      stat->rdev = inode->i_rdev;
  97.         30      stat->size = i_size_read(inode);
  98.         31      stat->atime = inode->i_atime;
  99.         32      stat->mtime = inode->i_mtime;
  100. ==>     33      stat->ctime = inode->i_ctime;      
  101.         34      stat->blksize = (1 << inode->i_blkbits);
  102.         35      stat->blocks = inode->i_blocks;
  103.         36  }
  104.         37 
  105.         38  EXPORT_SYMBOL(generic_fillattr);
  106.         39 
  107.         40  /**
  108.         41   * vfs_getattr_nosec - getattr without security checks
  109.         42   * @path: file to get attributes from
  110.         43   * @stat: structure to return attributes in
  111.  
  112. /linux-3.13.5/fs/ext4/inode.c:3769
  113.       3759      /*
  114.       3760       * If this was a simple ftruncate() and the file will remain alive,
  115.       3761       * then we need to clear up the orphan record which we created above.
  116.       3762       * However, if this was a real unlink then we were called by
  117.       3763       * ext4_delete_inode(), and we allow that function to clean up the
  118.       3764       * orphan info for us.
  119.       3765       */
  120.       3766      if (inode->i_nlink)
  121.       3767          ext4_orphan_del(handle, inode);
  122.       3768 
  123. ==>   3769      inode->i_mtime = inode->i_ctime = ext4_current_time(inode);      
  124.       3770      ext4_mark_inode_dirty(handle, inode);
  125.       3771      ext4_journal_stop(handle);
  126.       3772 
  127.       3773      trace_ext4_truncate_exit(inode);
  128.       3774  }
  129.       3775 
  130.       3776  /*
  131.       3777   * ext4_get_inode_loc returns with an extra refcount against the inode's
  132.       3778   * underlying buffer_head on success. If 'in_mem' is true, we have all
  133.       3779   * data in memory that is needed to recreate the on-disk version of this
  134.  
  135. ====================================================================================================================================================================================
  136. Variable: inode->i_blocks   Addresses: c10a9f75 c110ab50 c10aa048 c10aa894
  137. c10a9f75 __inode_sub_bytes /linux-3.13.5/fs/stat.c:471
  138. c110ab50 ext4_inode_blocks_set /linux-3.13.5/fs/ext4/inode.c:4238
  139. c10aa048 generic_fillattr /linux-3.13.5/fs/stat.c:35
  140. c10aa894 __inode_add_bytes /linux-3.13.5/fs/stat.c:451
  141.  
  142. c10a9f75 <-> c10aa048
  143. c10aa894 <-> c110ab50
  144. c10aa048 <-> c10aa894
  145. c10aa048 <-> c10aa894
  146.  
  147. /linux-3.13.5/fs/stat.c:471
  148.        461  {
  149.        462      spin_lock(&inode->i_lock);
  150.        463      __inode_add_bytes(inode, bytes);
  151.        464      spin_unlock(&inode->i_lock);
  152.        465  }
  153.        466 
  154.        467  EXPORT_SYMBOL(inode_add_bytes);
  155.        468 
  156.        469  void __inode_sub_bytes(struct inode *inode, loff_t bytes)
  157.        470  {
  158. ==>    471      inode->i_blocks -= bytes >> 9;      
  159.        472      bytes &= 511;
  160.        473      if (inode->i_bytes < bytes) {
  161.        474          inode->i_blocks--;
  162.        475          inode->i_bytes += 512;
  163.        476      }
  164.        477      inode->i_bytes -= bytes;
  165.        478  }
  166.        479 
  167.        480  EXPORT_SYMBOL(__inode_sub_bytes);
  168.        481 
  169.  
  170. /linux-3.13.5/fs/ext4/inode.c:4238
  171.       4228      brelse(iloc.bh);
  172.       4229      iget_failed(inode);
  173.       4230      return ERR_PTR(ret);
  174.       4231  }
  175.       4232 
  176.       4233  static int ext4_inode_blocks_set(handle_t *handle,
  177.       4234                  struct ext4_inode *raw_inode,
  178.       4235                  struct ext4_inode_info *ei)
  179.       4236  {
  180.       4237      struct inode *inode = &(ei->vfs_inode);
  181. ==>   4238      u64 i_blocks = inode->i_blocks;      
  182.       4239      struct super_block *sb = inode->i_sb;
  183.       4240 
  184.       4241      if (i_blocks <= ~0U) {
  185.       4242          /*
  186.       4243           * i_blocks can be represented in a 32 bit variable
  187.       4244           * as multiple of 512 bytes
  188.       4245           */
  189.       4246          raw_inode->i_blocks_lo   = cpu_to_le32(i_blocks);
  190.       4247          raw_inode->i_blocks_high = 0;
  191.       4248          ext4_clear_inode_flag(inode, EXT4_INODE_HUGE_FILE);
  192.  
  193. /linux-3.13.5/fs/stat.c:35
  194.         25      stat->mode = inode->i_mode;
  195.         26      stat->nlink = inode->i_nlink;
  196.         27      stat->uid = inode->i_uid;
  197.         28      stat->gid = inode->i_gid;
  198.         29      stat->rdev = inode->i_rdev;
  199.         30      stat->size = i_size_read(inode);
  200.         31      stat->atime = inode->i_atime;
  201.         32      stat->mtime = inode->i_mtime;
  202.         33      stat->ctime = inode->i_ctime;
  203.         34      stat->blksize = (1 << inode->i_blkbits);
  204. ==>     35      stat->blocks = inode->i_blocks;      
  205.         36  }
  206.         37 
  207.         38  EXPORT_SYMBOL(generic_fillattr);
  208.         39 
  209.         40  /**
  210.         41   * vfs_getattr_nosec - getattr without security checks
  211.         42   * @path: file to get attributes from
  212.         43   * @stat: structure to return attributes in
  213.         44   *
  214.         45   * Get attributes without calling security_inode_getattr.
  215.  
  216. /linux-3.13.5/fs/stat.c:451
  217.        441      error = vfs_fstatat(dfd, filename, &stat, flag);
  218.        442      if (error)
  219.        443          return error;
  220.        444      return cp_new_stat64(&stat, statbuf);
  221.        445  }
  222.        446  #endif /* __ARCH_WANT_STAT64 || __ARCH_WANT_COMPAT_STAT64 */
  223.        447 
  224.        448  /* Caller is here responsible for sufficient locking (ie. inode->i_lock) */
  225.        449  void __inode_add_bytes(struct inode *inode, loff_t bytes)
  226.        450  {
  227. ==>    451      inode->i_blocks += bytes >> 9;      
  228.        452      bytes &= 511;
  229.        453      inode->i_bytes += bytes;
  230.        454      if (inode->i_bytes >= 512) {
  231.        455          inode->i_blocks++;
  232.        456          inode->i_bytes -= 512;
  233.        457      }
  234.        458  }
  235.        459 
  236.        460  void inode_add_bytes(struct inode *inode, loff_t bytes)
  237.        461  {
  238.  
  239.  
  240. ====================================================================================================================================================================================
  241. Variable: inode->i_ctime    Addresses: c10b79e9 c110b22b c10aa02f
  242. c110b22b ext4_current_time /linux-3.13.5/fs/ext4/inode.c:3769
  243. c10b79e9 update_time /linux-3.13.5/fs/inode.c:1510
  244. c10aa02f generic_fillattr /linux-3.13.5/fs/stat.c:33
  245.  
  246. c110b22b <-> c10aa02f
  247. c10aa02f <-> c10b79e9
  248. c110b22b <-> c10aa02f
  249.  
  250. /linux-3.13.5/fs/ext4/inode.c:3769
  251.       3759      /*
  252.       3760       * If this was a simple ftruncate() and the file will remain alive,
  253.       3761       * then we need to clear up the orphan record which we created above.
  254.       3762       * However, if this was a real unlink then we were called by
  255.       3763       * ext4_delete_inode(), and we allow that function to clean up the
  256.       3764       * orphan info for us.
  257.       3765       */
  258.       3766      if (inode->i_nlink)
  259.       3767          ext4_orphan_del(handle, inode);
  260.       3768 
  261. ==>   3769      inode->i_mtime = inode->i_ctime = ext4_current_time(inode);      
  262.       3770      ext4_mark_inode_dirty(handle, inode);
  263.       3771      ext4_journal_stop(handle);
  264.       3772 
  265.       3773      trace_ext4_truncate_exit(inode);
  266.       3774  }
  267.       3775 
  268.       3776  /*
  269.       3777   * ext4_get_inode_loc returns with an extra refcount against the inode's
  270.       3778   * underlying buffer_head on success. If 'in_mem' is true, we have all
  271.       3779   * data in memory that is needed to recreate the on-disk version of this
  272.  
  273. /linux-3.13.5/fs/inode.c:1510
  274.       1500  static int update_time(struct inode *inode, struct timespec *time, int flags)
  275.       1501  {
  276.       1502      if (inode->i_op->update_time)
  277.       1503          return inode->i_op->update_time(inode, time, flags);
  278.       1504 
  279.       1505      if (flags & S_ATIME)
  280.       1506          inode->i_atime = *time;
  281.       1507      if (flags & S_VERSION)
  282.       1508          inode_inc_iversion(inode);
  283.       1509      if (flags & S_CTIME)
  284. ==>   1510          inode->i_ctime = *time;      
  285.       1511      if (flags & S_MTIME)
  286.       1512          inode->i_mtime = *time;
  287.       1513      mark_inode_dirty_sync(inode);
  288.       1514      return 0;
  289.       1515  }
  290.       1516 
  291.       1517  /**
  292.       1518   *  touch_atime -   update the access time
  293.       1519   *  @path: the &struct path to update
  294.       1520   *
  295.  
  296. /linux-3.13.5/fs/stat.c:33
  297.         23      stat->dev = inode->i_sb->s_dev;
  298.         24      stat->ino = inode->i_ino;
  299.         25      stat->mode = inode->i_mode;
  300.         26      stat->nlink = inode->i_nlink;
  301.         27      stat->uid = inode->i_uid;
  302.         28      stat->gid = inode->i_gid;
  303.         29      stat->rdev = inode->i_rdev;
  304.         30      stat->size = i_size_read(inode);
  305.         31      stat->atime = inode->i_atime;
  306.         32      stat->mtime = inode->i_mtime;
  307. ==>     33      stat->ctime = inode->i_ctime;      
  308.         34      stat->blksize = (1 << inode->i_blkbits);
  309.         35      stat->blocks = inode->i_blocks;
  310.         36  }
  311.         37 
  312.         38  EXPORT_SYMBOL(generic_fillattr);
  313.         39 
  314.         40  /**
  315.         41   * vfs_getattr_nosec - getattr without security checks
  316.         42   * @path: file to get attributes from
  317.         43   * @stat: structure to return attributes in
  318.  
  319.  
  320. ====================================================================================================================================================================================
  321. Variable: inode->i_atime    Addresses: c10b7f62 c10b79a9 c10aa017 c10b7fcb
  322. c10b7f62 timespec_compare /linux-3.13.5/include/linux/time.h:35
  323. c10b7fcb timespec_equal /linux-3.13.5/include/linux/time.h:25
  324. c10aa017 generic_fillattr /linux-3.13.5/fs/stat.c:31
  325. c10b79a9 update_time /linux-3.13.5/fs/inode.c:1506
  326.  
  327. c10b7f62 <-> c10b79a9
  328. c10b7fcb <-> c10b79a9
  329. c10aa017 <-> c10b79a9
  330. c10b7fcb <-> c10b79a9
  331.  
  332. /linux-3.13.5/include/linux/time.h:35
  333.         25      return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
  334.         26  }
  335.         27 
  336.         28  /*
  337.         29   * lhs < rhs:  return <0
  338.         30   * lhs == rhs: return 0
  339.         31   * lhs > rhs:  return >0
  340.         32   */
  341.         33  static inline int timespec_compare(const struct timespec *lhs, const struct timespec *rhs)
  342.         34  {
  343. ==>     35      if (lhs->tv_sec < rhs->tv_sec)      
  344.         36          return -1;
  345.         37      if (lhs->tv_sec > rhs->tv_sec)
  346.         38          return 1;
  347.         39      return lhs->tv_nsec - rhs->tv_nsec;
  348.         40  }
  349.         41 
  350.         42  static inline int timeval_compare(const struct timeval *lhs, const struct timeval *rhs)
  351.         43  {
  352.         44      if (lhs->tv_sec < rhs->tv_sec)
  353.         45          return -1;
  354.  
  355. /linux-3.13.5/include/linux/time.h:25
  356.         15  #define NSEC_PER_MSEC   1000000L
  357.         16  #define USEC_PER_SEC    1000000L
  358.         17  #define NSEC_PER_SEC    1000000000L
  359.         18  #define FSEC_PER_SEC    1000000000000000LL
  360.         19 
  361.         20  #define TIME_T_MAX  (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)
  362.         21 
  363.         22  static inline int timespec_equal(const struct timespec *a,
  364.         23                                   const struct timespec *b)
  365.         24  {
  366. ==>     25      return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);      
  367.         26  }
  368.         27 
  369.         28  /*
  370.         29   * lhs < rhs:  return <0
  371.         30   * lhs == rhs: return 0
  372.         31   * lhs > rhs:  return >0
  373.         32   */
  374.         33  static inline int timespec_compare(const struct timespec *lhs, const struct timespec *rhs)
  375.         34  {
  376.         35      if (lhs->tv_sec < rhs->tv_sec)
  377.  
  378. /linux-3.13.5/fs/stat.c:31
  379.         21  void generic_fillattr(struct inode *inode, struct kstat *stat)
  380.         22  {
  381.         23      stat->dev = inode->i_sb->s_dev;
  382.         24      stat->ino = inode->i_ino;
  383.         25      stat->mode = inode->i_mode;
  384.         26      stat->nlink = inode->i_nlink;
  385.         27      stat->uid = inode->i_uid;
  386.         28      stat->gid = inode->i_gid;
  387.         29      stat->rdev = inode->i_rdev;
  388.         30      stat->size = i_size_read(inode);
  389. ==>     31      stat->atime = inode->i_atime;      
  390.         32      stat->mtime = inode->i_mtime;
  391.         33      stat->ctime = inode->i_ctime;
  392.         34      stat->blksize = (1 << inode->i_blkbits);
  393.         35      stat->blocks = inode->i_blocks;
  394.         36  }
  395.         37 
  396.         38  EXPORT_SYMBOL(generic_fillattr);
  397.         39 
  398.         40  /**
  399.         41   * vfs_getattr_nosec - getattr without security checks
  400.  
  401. /linux-3.13.5/fs/inode.c:1506
  402.       1496  /*
  403.       1497   * This does the actual work of updating an inodes time or version.  Must have
  404.       1498   * had called mnt_want_write() before calling this.
  405.       1499   */
  406.       1500  static int update_time(struct inode *inode, struct timespec *time, int flags)
  407.       1501  {
  408.       1502      if (inode->i_op->update_time)
  409.       1503          return inode->i_op->update_time(inode, time, flags);
  410.       1504 
  411.       1505      if (flags & S_ATIME)
  412. ==>   1506          inode->i_atime = *time;      
  413.       1507      if (flags & S_VERSION)
  414.       1508          inode_inc_iversion(inode);
  415.       1509      if (flags & S_CTIME)
  416.       1510          inode->i_ctime = *time;
  417.       1511      if (flags & S_MTIME)
  418.       1512          inode->i_mtime = *time;
  419.       1513      mark_inode_dirty_sync(inode);
  420.       1514      return 0;
  421.       1515  }
  422.       1516 
  423.  
  424.  
  425. ====================================================================================================================================================================================
  426. Variable: inode->i_mtime    Addresses: c10b79f9 c10aa023 c110b237
  427. c110b237 ext4_truncate /linux-3.13.5/fs/ext4/inode.c:3769
  428. c10b79f9 update_time /linux-3.13.5/fs/inode.c:1512
  429. c10aa023 generic_fillattr /linux-3.13.5/fs/stat.c:32
  430.  
  431. c10aa023 <-> c110b237
  432. c10b79f9 <-> c10aa023
  433. c10b79f9 <-> c10aa023
  434.  
  435. /linux-3.13.5/fs/ext4/inode.c:3769
  436.       3759      /*
  437.       3760       * If this was a simple ftruncate() and the file will remain alive,
  438.       3761       * then we need to clear up the orphan record which we created above.
  439.       3762       * However, if this was a real unlink then we were called by
  440.       3763       * ext4_delete_inode(), and we allow that function to clean up the
  441.       3764       * orphan info for us.
  442.       3765       */
  443.       3766      if (inode->i_nlink)
  444.       3767          ext4_orphan_del(handle, inode);
  445.       3768 
  446. ==>   3769      inode->i_mtime = inode->i_ctime = ext4_current_time(inode);      
  447.       3770      ext4_mark_inode_dirty(handle, inode);
  448.       3771      ext4_journal_stop(handle);
  449.       3772 
  450.       3773      trace_ext4_truncate_exit(inode);
  451.       3774  }
  452.       3775 
  453.       3776  /*
  454.       3777   * ext4_get_inode_loc returns with an extra refcount against the inode's
  455.       3778   * underlying buffer_head on success. If 'in_mem' is true, we have all
  456.       3779   * data in memory that is needed to recreate the on-disk version of this
  457.  
  458. /linux-3.13.5/fs/inode.c:1512
  459.       1502      if (inode->i_op->update_time)
  460.       1503          return inode->i_op->update_time(inode, time, flags);
  461.       1504 
  462.       1505      if (flags & S_ATIME)
  463.       1506          inode->i_atime = *time;
  464.       1507      if (flags & S_VERSION)
  465.       1508          inode_inc_iversion(inode);
  466.       1509      if (flags & S_CTIME)
  467.       1510          inode->i_ctime = *time;
  468.       1511      if (flags & S_MTIME)
  469. ==>   1512          inode->i_mtime = *time;      
  470.       1513      mark_inode_dirty_sync(inode);
  471.       1514      return 0;
  472.       1515  }
  473.       1516 
  474.       1517  /**
  475.       1518   *  touch_atime -   update the access time
  476.       1519   *  @path: the &struct path to update
  477.       1520   *
  478.       1521   *  Update the accessed time on an inode and mark it for writeback.
  479.       1522   *  This function automatically handles read only file systems and media,
  480.  
  481. /linux-3.13.5/fs/stat.c:32
  482.         22  {
  483.         23      stat->dev = inode->i_sb->s_dev;
  484.         24      stat->ino = inode->i_ino;
  485.         25      stat->mode = inode->i_mode;
  486.         26      stat->nlink = inode->i_nlink;
  487.         27      stat->uid = inode->i_uid;
  488.         28      stat->gid = inode->i_gid;
  489.         29      stat->rdev = inode->i_rdev;
  490.         30      stat->size = i_size_read(inode);
  491.         31      stat->atime = inode->i_atime;
  492. ==>     32      stat->mtime = inode->i_mtime;      
  493.         33      stat->ctime = inode->i_ctime;
  494.         34      stat->blksize = (1 << inode->i_blkbits);
  495.         35      stat->blocks = inode->i_blocks;
  496.         36  }
  497.         37 
  498.         38  EXPORT_SYMBOL(generic_fillattr);
  499.         39 
  500.         40  /**
  501.         41   * vfs_getattr_nosec - getattr without security checks
  502.         42   * @path: file to get attributes from
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement