aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2013-12-12 19:00:43 -0500
committerDave Chinner <david@fromorbit.com>2013-12-12 19:00:43 -0500
commitce9641d6c981aad0463b2d1455f0b60e5c8671c5 (patch)
treef5b07df05879ff2612d39a38b858f881d172fa3a
parent7aeb72224120e0c49ba4c93d75f8f0d6a87f6afd (diff)
xfs: refactor xfs_inode_item_size
Split out two helpers to size the data and attribute to make the function more readable. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_inode_item.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 7c0d391f9a6e..050d2540f7b4 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -39,27 +39,14 @@ static inline struct xfs_inode_log_item *INODE_ITEM(struct xfs_log_item *lip)
39 return container_of(lip, struct xfs_inode_log_item, ili_item); 39 return container_of(lip, struct xfs_inode_log_item, ili_item);
40} 40}
41 41
42
43/*
44 * This returns the number of iovecs needed to log the given inode item.
45 *
46 * We need one iovec for the inode log format structure, one for the
47 * inode core, and possibly one for the inode data/extents/b-tree root
48 * and one for the inode attribute data/extents/b-tree root.
49 */
50STATIC void 42STATIC void
51xfs_inode_item_size( 43xfs_inode_item_data_fork_size(
52 struct xfs_log_item *lip, 44 struct xfs_inode_log_item *iip,
53 int *nvecs, 45 int *nvecs,
54 int *nbytes) 46 int *nbytes)
55{ 47{
56 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
57 struct xfs_inode *ip = iip->ili_inode; 48 struct xfs_inode *ip = iip->ili_inode;
58 49
59 *nvecs += 2;
60 *nbytes += sizeof(struct xfs_inode_log_format) +
61 xfs_icdinode_size(ip->i_d.di_version);
62
63 switch (ip->i_d.di_format) { 50 switch (ip->i_d.di_format) {
64 case XFS_DINODE_FMT_EXTENTS: 51 case XFS_DINODE_FMT_EXTENTS:
65 if ((iip->ili_fields & XFS_ILOG_DEXT) && 52 if ((iip->ili_fields & XFS_ILOG_DEXT) &&
@@ -70,7 +57,6 @@ xfs_inode_item_size(
70 *nvecs += 1; 57 *nvecs += 1;
71 } 58 }
72 break; 59 break;
73
74 case XFS_DINODE_FMT_BTREE: 60 case XFS_DINODE_FMT_BTREE:
75 if ((iip->ili_fields & XFS_ILOG_DBROOT) && 61 if ((iip->ili_fields & XFS_ILOG_DBROOT) &&
76 ip->i_df.if_broot_bytes > 0) { 62 ip->i_df.if_broot_bytes > 0) {
@@ -78,7 +64,6 @@ xfs_inode_item_size(
78 *nvecs += 1; 64 *nvecs += 1;
79 } 65 }
80 break; 66 break;
81
82 case XFS_DINODE_FMT_LOCAL: 67 case XFS_DINODE_FMT_LOCAL:
83 if ((iip->ili_fields & XFS_ILOG_DDATA) && 68 if ((iip->ili_fields & XFS_ILOG_DDATA) &&
84 ip->i_df.if_bytes > 0) { 69 ip->i_df.if_bytes > 0) {
@@ -90,19 +75,20 @@ xfs_inode_item_size(
90 case XFS_DINODE_FMT_DEV: 75 case XFS_DINODE_FMT_DEV:
91 case XFS_DINODE_FMT_UUID: 76 case XFS_DINODE_FMT_UUID:
92 break; 77 break;
93
94 default: 78 default:
95 ASSERT(0); 79 ASSERT(0);
96 break; 80 break;
97 } 81 }
82}
98 83
99 if (!XFS_IFORK_Q(ip)) 84STATIC void
100 return; 85xfs_inode_item_attr_fork_size(
101 86 struct xfs_inode_log_item *iip,
87 int *nvecs,
88 int *nbytes)
89{
90 struct xfs_inode *ip = iip->ili_inode;
102 91
103 /*
104 * Log any necessary attribute data.
105 */
106 switch (ip->i_d.di_aformat) { 92 switch (ip->i_d.di_aformat) {
107 case XFS_DINODE_FMT_EXTENTS: 93 case XFS_DINODE_FMT_EXTENTS:
108 if ((iip->ili_fields & XFS_ILOG_AEXT) && 94 if ((iip->ili_fields & XFS_ILOG_AEXT) &&
@@ -113,7 +99,6 @@ xfs_inode_item_size(
113 *nvecs += 1; 99 *nvecs += 1;
114 } 100 }
115 break; 101 break;
116
117 case XFS_DINODE_FMT_BTREE: 102 case XFS_DINODE_FMT_BTREE:
118 if ((iip->ili_fields & XFS_ILOG_ABROOT) && 103 if ((iip->ili_fields & XFS_ILOG_ABROOT) &&
119 ip->i_afp->if_broot_bytes > 0) { 104 ip->i_afp->if_broot_bytes > 0) {
@@ -121,7 +106,6 @@ xfs_inode_item_size(
121 *nvecs += 1; 106 *nvecs += 1;
122 } 107 }
123 break; 108 break;
124
125 case XFS_DINODE_FMT_LOCAL: 109 case XFS_DINODE_FMT_LOCAL:
126 if ((iip->ili_fields & XFS_ILOG_ADATA) && 110 if ((iip->ili_fields & XFS_ILOG_ADATA) &&
127 ip->i_afp->if_bytes > 0) { 111 ip->i_afp->if_bytes > 0) {
@@ -129,7 +113,6 @@ xfs_inode_item_size(
129 *nvecs += 1; 113 *nvecs += 1;
130 } 114 }
131 break; 115 break;
132
133 default: 116 default:
134 ASSERT(0); 117 ASSERT(0);
135 break; 118 break;
@@ -137,6 +120,31 @@ xfs_inode_item_size(
137} 120}
138 121
139/* 122/*
123 * This returns the number of iovecs needed to log the given inode item.
124 *
125 * We need one iovec for the inode log format structure, one for the
126 * inode core, and possibly one for the inode data/extents/b-tree root
127 * and one for the inode attribute data/extents/b-tree root.
128 */
129STATIC void
130xfs_inode_item_size(
131 struct xfs_log_item *lip,
132 int *nvecs,
133 int *nbytes)
134{
135 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
136 struct xfs_inode *ip = iip->ili_inode;
137
138 *nvecs += 2;
139 *nbytes += sizeof(struct xfs_inode_log_format) +
140 xfs_icdinode_size(ip->i_d.di_version);
141
142 xfs_inode_item_data_fork_size(iip, nvecs, nbytes);
143 if (XFS_IFORK_Q(ip))
144 xfs_inode_item_attr_fork_size(iip, nvecs, nbytes);
145}
146
147/*
140 * xfs_inode_item_format_extents - convert in-core extents to on-disk form 148 * xfs_inode_item_format_extents - convert in-core extents to on-disk form
141 * 149 *
142 * For either the data or attr fork in extent format, we need to endian convert 150 * For either the data or attr fork in extent format, we need to endian convert