aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r--fs/xfs/xfs_inode.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 4ec5b7f45401..801274126648 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -39,6 +39,7 @@
39#include "xfs_ialloc.h" 39#include "xfs_ialloc.h"
40#include "xfs_bmap.h" 40#include "xfs_bmap.h"
41#include "xfs_bmap_util.h" 41#include "xfs_bmap_util.h"
42#include "xfs_errortag.h"
42#include "xfs_error.h" 43#include "xfs_error.h"
43#include "xfs_quota.h" 44#include "xfs_quota.h"
44#include "xfs_filestream.h" 45#include "xfs_filestream.h"
@@ -384,14 +385,6 @@ xfs_isilocked(
384} 385}
385#endif 386#endif
386 387
387#ifdef DEBUG
388int xfs_locked_n;
389int xfs_small_retries;
390int xfs_middle_retries;
391int xfs_lots_retries;
392int xfs_lock_delays;
393#endif
394
395/* 388/*
396 * xfs_lockdep_subclass_ok() is only used in an ASSERT, so is only called when 389 * xfs_lockdep_subclass_ok() is only used in an ASSERT, so is only called when
397 * DEBUG or XFS_WARN is set. And MAX_LOCKDEP_SUBCLASSES is then only defined 390 * DEBUG or XFS_WARN is set. And MAX_LOCKDEP_SUBCLASSES is then only defined
@@ -544,24 +537,11 @@ again:
544 537
545 if ((attempts % 5) == 0) { 538 if ((attempts % 5) == 0) {
546 delay(1); /* Don't just spin the CPU */ 539 delay(1); /* Don't just spin the CPU */
547#ifdef DEBUG
548 xfs_lock_delays++;
549#endif
550 } 540 }
551 i = 0; 541 i = 0;
552 try_lock = 0; 542 try_lock = 0;
553 goto again; 543 goto again;
554 } 544 }
555
556#ifdef DEBUG
557 if (attempts) {
558 if (attempts < 5) xfs_small_retries++;
559 else if (attempts < 100) xfs_middle_retries++;
560 else xfs_lots_retries++;
561 } else {
562 xfs_locked_n++;
563 }
564#endif
565} 545}
566 546
567/* 547/*
@@ -767,7 +747,7 @@ xfs_ialloc(
767 xfs_inode_t *pip, 747 xfs_inode_t *pip,
768 umode_t mode, 748 umode_t mode,
769 xfs_nlink_t nlink, 749 xfs_nlink_t nlink,
770 xfs_dev_t rdev, 750 dev_t rdev,
771 prid_t prid, 751 prid_t prid,
772 int okalloc, 752 int okalloc,
773 xfs_buf_t **ialloc_context, 753 xfs_buf_t **ialloc_context,
@@ -819,6 +799,7 @@ xfs_ialloc(
819 set_nlink(inode, nlink); 799 set_nlink(inode, nlink);
820 ip->i_d.di_uid = xfs_kuid_to_uid(current_fsuid()); 800 ip->i_d.di_uid = xfs_kuid_to_uid(current_fsuid());
821 ip->i_d.di_gid = xfs_kgid_to_gid(current_fsgid()); 801 ip->i_d.di_gid = xfs_kgid_to_gid(current_fsgid());
802 inode->i_rdev = rdev;
822 xfs_set_projid(ip, prid); 803 xfs_set_projid(ip, prid);
823 804
824 if (pip && XFS_INHERIT_GID(pip)) { 805 if (pip && XFS_INHERIT_GID(pip)) {
@@ -867,7 +848,6 @@ xfs_ialloc(
867 case S_IFBLK: 848 case S_IFBLK:
868 case S_IFSOCK: 849 case S_IFSOCK:
869 ip->i_d.di_format = XFS_DINODE_FMT_DEV; 850 ip->i_d.di_format = XFS_DINODE_FMT_DEV;
870 ip->i_df.if_u2.if_rdev = rdev;
871 ip->i_df.if_flags = 0; 851 ip->i_df.if_flags = 0;
872 flags |= XFS_ILOG_DEV; 852 flags |= XFS_ILOG_DEV;
873 break; 853 break;
@@ -933,7 +913,7 @@ xfs_ialloc(
933 ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS; 913 ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
934 ip->i_df.if_flags = XFS_IFEXTENTS; 914 ip->i_df.if_flags = XFS_IFEXTENTS;
935 ip->i_df.if_bytes = ip->i_df.if_real_bytes = 0; 915 ip->i_df.if_bytes = ip->i_df.if_real_bytes = 0;
936 ip->i_df.if_u1.if_extents = NULL; 916 ip->i_df.if_u1.if_root = NULL;
937 break; 917 break;
938 default: 918 default:
939 ASSERT(0); 919 ASSERT(0);
@@ -975,7 +955,7 @@ xfs_dir_ialloc(
975 the inode. */ 955 the inode. */
976 umode_t mode, 956 umode_t mode,
977 xfs_nlink_t nlink, 957 xfs_nlink_t nlink,
978 xfs_dev_t rdev, 958 dev_t rdev,
979 prid_t prid, /* project id */ 959 prid_t prid, /* project id */
980 int okalloc, /* ok to allocate new space */ 960 int okalloc, /* ok to allocate new space */
981 xfs_inode_t **ipp, /* pointer to inode; it will be 961 xfs_inode_t **ipp, /* pointer to inode; it will be
@@ -1147,7 +1127,7 @@ xfs_create(
1147 xfs_inode_t *dp, 1127 xfs_inode_t *dp,
1148 struct xfs_name *name, 1128 struct xfs_name *name,
1149 umode_t mode, 1129 umode_t mode,
1150 xfs_dev_t rdev, 1130 dev_t rdev,
1151 xfs_inode_t **ipp) 1131 xfs_inode_t **ipp)
1152{ 1132{
1153 int is_dir = S_ISDIR(mode); 1133 int is_dir = S_ISDIR(mode);
@@ -1183,7 +1163,6 @@ xfs_create(
1183 return error; 1163 return error;
1184 1164
1185 if (is_dir) { 1165 if (is_dir) {
1186 rdev = 0;
1187 resblks = XFS_MKDIR_SPACE_RES(mp, name->len); 1166 resblks = XFS_MKDIR_SPACE_RES(mp, name->len);
1188 tres = &M_RES(mp)->tr_mkdir; 1167 tres = &M_RES(mp)->tr_mkdir;
1189 } else { 1168 } else {
@@ -2378,6 +2357,7 @@ retry:
2378 */ 2357 */
2379 if (ip->i_ino != inum + i) { 2358 if (ip->i_ino != inum + i) {
2380 xfs_iunlock(ip, XFS_ILOCK_EXCL); 2359 xfs_iunlock(ip, XFS_ILOCK_EXCL);
2360 rcu_read_unlock();
2381 continue; 2361 continue;
2382 } 2362 }
2383 } 2363 }
@@ -2421,6 +2401,24 @@ retry:
2421} 2401}
2422 2402
2423/* 2403/*
2404 * Free any local-format buffers sitting around before we reset to
2405 * extents format.
2406 */
2407static inline void
2408xfs_ifree_local_data(
2409 struct xfs_inode *ip,
2410 int whichfork)
2411{
2412 struct xfs_ifork *ifp;
2413
2414 if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL)
2415 return;
2416
2417 ifp = XFS_IFORK_PTR(ip, whichfork);
2418 xfs_idata_realloc(ip, -ifp->if_bytes, whichfork);
2419}
2420
2421/*
2424 * This is called to return an inode to the inode free list. 2422 * This is called to return an inode to the inode free list.
2425 * The inode should already be truncated to 0 length and have 2423 * The inode should already be truncated to 0 length and have
2426 * no pages associated with it. This routine also assumes that 2424 * no pages associated with it. This routine also assumes that
@@ -2457,6 +2455,9 @@ xfs_ifree(
2457 if (error) 2455 if (error)
2458 return error; 2456 return error;
2459 2457
2458 xfs_ifree_local_data(ip, XFS_DATA_FORK);
2459 xfs_ifree_local_data(ip, XFS_ATTR_FORK);
2460
2460 VFS_I(ip)->i_mode = 0; /* mark incore inode as free */ 2461 VFS_I(ip)->i_mode = 0; /* mark incore inode as free */
2461 ip->i_d.di_flags = 0; 2462 ip->i_d.di_flags = 0;
2462 ip->i_d.di_dmevmask = 0; 2463 ip->i_d.di_dmevmask = 0;