diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-08-12 06:50:04 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-08-13 17:10:21 -0400 |
commit | 166d13688a0e2d0aa379e259af8e2ee6a401de9a (patch) | |
tree | 2f30092475185ee80d941e0be7689a0f5151be9f | |
parent | 050a1952c3f9304eccddc4f084e2401b5205ff55 (diff) |
xfs: return log item size in IOP_SIZE
To begin optimising the CIL commit process, we need to have IOP_SIZE
return both the number of vectors and the size of the data pointed
to by the vectors. This enables us to calculate the size ofthe
memory allocation needed before the formatting step and reduces the
number of memory allocations per item by one.
While there, kill the IOP_SIZE macro.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
-rw-r--r-- | fs/xfs/xfs_buf_item.c | 52 | ||||
-rw-r--r-- | fs/xfs/xfs_dquot_item.c | 22 | ||||
-rw-r--r-- | fs/xfs/xfs_extfree_item.c | 50 | ||||
-rw-r--r-- | fs/xfs/xfs_icreate_item.c | 9 | ||||
-rw-r--r-- | fs/xfs/xfs_inode_item.c | 53 | ||||
-rw-r--r-- | fs/xfs/xfs_log_cil.c | 10 | ||||
-rw-r--r-- | fs/xfs/xfs_trans.h | 3 |
7 files changed, 126 insertions, 73 deletions
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index bfc4e0c26fd3..9358504e4b68 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
@@ -39,6 +39,14 @@ static inline struct xfs_buf_log_item *BUF_ITEM(struct xfs_log_item *lip) | |||
39 | 39 | ||
40 | STATIC void xfs_buf_do_callbacks(struct xfs_buf *bp); | 40 | STATIC void xfs_buf_do_callbacks(struct xfs_buf *bp); |
41 | 41 | ||
42 | static inline int | ||
43 | xfs_buf_log_format_size( | ||
44 | struct xfs_buf_log_format *blfp) | ||
45 | { | ||
46 | return offsetof(struct xfs_buf_log_format, blf_data_map) + | ||
47 | (blfp->blf_map_size * sizeof(blfp->blf_data_map[0])); | ||
48 | } | ||
49 | |||
42 | /* | 50 | /* |
43 | * This returns the number of log iovecs needed to log the | 51 | * This returns the number of log iovecs needed to log the |
44 | * given buf log item. | 52 | * given buf log item. |
@@ -49,25 +57,27 @@ STATIC void xfs_buf_do_callbacks(struct xfs_buf *bp); | |||
49 | * | 57 | * |
50 | * If the XFS_BLI_STALE flag has been set, then log nothing. | 58 | * If the XFS_BLI_STALE flag has been set, then log nothing. |
51 | */ | 59 | */ |
52 | STATIC uint | 60 | STATIC void |
53 | xfs_buf_item_size_segment( | 61 | xfs_buf_item_size_segment( |
54 | struct xfs_buf_log_item *bip, | 62 | struct xfs_buf_log_item *bip, |
55 | struct xfs_buf_log_format *blfp) | 63 | struct xfs_buf_log_format *blfp, |
64 | int *nvecs, | ||
65 | int *nbytes) | ||
56 | { | 66 | { |
57 | struct xfs_buf *bp = bip->bli_buf; | 67 | struct xfs_buf *bp = bip->bli_buf; |
58 | uint nvecs; | ||
59 | int next_bit; | 68 | int next_bit; |
60 | int last_bit; | 69 | int last_bit; |
61 | 70 | ||
62 | last_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0); | 71 | last_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0); |
63 | if (last_bit == -1) | 72 | if (last_bit == -1) |
64 | return 0; | 73 | return; |
65 | 74 | ||
66 | /* | 75 | /* |
67 | * initial count for a dirty buffer is 2 vectors - the format structure | 76 | * initial count for a dirty buffer is 2 vectors - the format structure |
68 | * and the first dirty region. | 77 | * and the first dirty region. |
69 | */ | 78 | */ |
70 | nvecs = 2; | 79 | *nvecs += 2; |
80 | *nbytes += xfs_buf_log_format_size(blfp) + XFS_BLF_CHUNK; | ||
71 | 81 | ||
72 | while (last_bit != -1) { | 82 | while (last_bit != -1) { |
73 | /* | 83 | /* |
@@ -87,18 +97,17 @@ xfs_buf_item_size_segment( | |||
87 | break; | 97 | break; |
88 | } else if (next_bit != last_bit + 1) { | 98 | } else if (next_bit != last_bit + 1) { |
89 | last_bit = next_bit; | 99 | last_bit = next_bit; |
90 | nvecs++; | 100 | (*nvecs)++; |
91 | } else if (xfs_buf_offset(bp, next_bit * XFS_BLF_CHUNK) != | 101 | } else if (xfs_buf_offset(bp, next_bit * XFS_BLF_CHUNK) != |
92 | (xfs_buf_offset(bp, last_bit * XFS_BLF_CHUNK) + | 102 | (xfs_buf_offset(bp, last_bit * XFS_BLF_CHUNK) + |
93 | XFS_BLF_CHUNK)) { | 103 | XFS_BLF_CHUNK)) { |
94 | last_bit = next_bit; | 104 | last_bit = next_bit; |
95 | nvecs++; | 105 | (*nvecs)++; |
96 | } else { | 106 | } else { |
97 | last_bit++; | 107 | last_bit++; |
98 | } | 108 | } |
109 | *nbytes += XFS_BLF_CHUNK; | ||
99 | } | 110 | } |
100 | |||
101 | return nvecs; | ||
102 | } | 111 | } |
103 | 112 | ||
104 | /* | 113 | /* |
@@ -118,12 +127,13 @@ xfs_buf_item_size_segment( | |||
118 | * If the XFS_BLI_STALE flag has been set, then log nothing but the buf log | 127 | * If the XFS_BLI_STALE flag has been set, then log nothing but the buf log |
119 | * format structures. | 128 | * format structures. |
120 | */ | 129 | */ |
121 | STATIC uint | 130 | STATIC void |
122 | xfs_buf_item_size( | 131 | xfs_buf_item_size( |
123 | struct xfs_log_item *lip) | 132 | struct xfs_log_item *lip, |
133 | int *nvecs, | ||
134 | int *nbytes) | ||
124 | { | 135 | { |
125 | struct xfs_buf_log_item *bip = BUF_ITEM(lip); | 136 | struct xfs_buf_log_item *bip = BUF_ITEM(lip); |
126 | uint nvecs; | ||
127 | int i; | 137 | int i; |
128 | 138 | ||
129 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 139 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
@@ -135,7 +145,11 @@ xfs_buf_item_size( | |||
135 | */ | 145 | */ |
136 | trace_xfs_buf_item_size_stale(bip); | 146 | trace_xfs_buf_item_size_stale(bip); |
137 | ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL); | 147 | ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL); |
138 | return bip->bli_format_count; | 148 | *nvecs += bip->bli_format_count; |
149 | for (i = 0; i < bip->bli_format_count; i++) { | ||
150 | *nbytes += xfs_buf_log_format_size(&bip->bli_formats[i]); | ||
151 | } | ||
152 | return; | ||
139 | } | 153 | } |
140 | 154 | ||
141 | ASSERT(bip->bli_flags & XFS_BLI_LOGGED); | 155 | ASSERT(bip->bli_flags & XFS_BLI_LOGGED); |
@@ -147,7 +161,8 @@ xfs_buf_item_size( | |||
147 | * commit, so no vectors are used at all. | 161 | * commit, so no vectors are used at all. |
148 | */ | 162 | */ |
149 | trace_xfs_buf_item_size_ordered(bip); | 163 | trace_xfs_buf_item_size_ordered(bip); |
150 | return XFS_LOG_VEC_ORDERED; | 164 | *nvecs = XFS_LOG_VEC_ORDERED; |
165 | return; | ||
151 | } | 166 | } |
152 | 167 | ||
153 | /* | 168 | /* |
@@ -159,13 +174,11 @@ xfs_buf_item_size( | |||
159 | * count for the extra buf log format structure that will need to be | 174 | * count for the extra buf log format structure that will need to be |
160 | * written. | 175 | * written. |
161 | */ | 176 | */ |
162 | nvecs = 0; | ||
163 | for (i = 0; i < bip->bli_format_count; i++) { | 177 | for (i = 0; i < bip->bli_format_count; i++) { |
164 | nvecs += xfs_buf_item_size_segment(bip, &bip->bli_formats[i]); | 178 | xfs_buf_item_size_segment(bip, &bip->bli_formats[i], |
179 | nvecs, nbytes); | ||
165 | } | 180 | } |
166 | |||
167 | trace_xfs_buf_item_size(bip); | 181 | trace_xfs_buf_item_size(bip); |
168 | return nvecs; | ||
169 | } | 182 | } |
170 | 183 | ||
171 | static struct xfs_log_iovec * | 184 | static struct xfs_log_iovec * |
@@ -192,8 +205,7 @@ xfs_buf_item_format_segment( | |||
192 | * the actual size of the dirty bitmap rather than the size of the in | 205 | * the actual size of the dirty bitmap rather than the size of the in |
193 | * memory structure. | 206 | * memory structure. |
194 | */ | 207 | */ |
195 | base_size = offsetof(struct xfs_buf_log_format, blf_data_map) + | 208 | base_size = xfs_buf_log_format_size(blfp); |
196 | (blfp->blf_map_size * sizeof(blfp->blf_data_map[0])); | ||
197 | 209 | ||
198 | nvecs = 0; | 210 | nvecs = 0; |
199 | first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0); | 211 | first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0); |
diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c index f07a4365def6..60c6e1f12695 100644 --- a/fs/xfs/xfs_dquot_item.c +++ b/fs/xfs/xfs_dquot_item.c | |||
@@ -44,14 +44,15 @@ static inline struct xfs_dq_logitem *DQUOT_ITEM(struct xfs_log_item *lip) | |||
44 | /* | 44 | /* |
45 | * returns the number of iovecs needed to log the given dquot item. | 45 | * returns the number of iovecs needed to log the given dquot item. |
46 | */ | 46 | */ |
47 | STATIC uint | 47 | STATIC void |
48 | xfs_qm_dquot_logitem_size( | 48 | xfs_qm_dquot_logitem_size( |
49 | struct xfs_log_item *lip) | 49 | struct xfs_log_item *lip, |
50 | int *nvecs, | ||
51 | int *nbytes) | ||
50 | { | 52 | { |
51 | /* | 53 | *nvecs += 2; |
52 | * we need only two iovecs, one for the format, one for the real thing | 54 | *nbytes += sizeof(struct xfs_dq_logformat) + |
53 | */ | 55 | sizeof(struct xfs_disk_dquot); |
54 | return 2; | ||
55 | } | 56 | } |
56 | 57 | ||
57 | /* | 58 | /* |
@@ -286,11 +287,14 @@ static inline struct xfs_qoff_logitem *QOFF_ITEM(struct xfs_log_item *lip) | |||
286 | * We only need 1 iovec for an quotaoff item. It just logs the | 287 | * We only need 1 iovec for an quotaoff item. It just logs the |
287 | * quotaoff_log_format structure. | 288 | * quotaoff_log_format structure. |
288 | */ | 289 | */ |
289 | STATIC uint | 290 | STATIC void |
290 | xfs_qm_qoff_logitem_size( | 291 | xfs_qm_qoff_logitem_size( |
291 | struct xfs_log_item *lip) | 292 | struct xfs_log_item *lip, |
293 | int *nvecs, | ||
294 | int *nbytes) | ||
292 | { | 295 | { |
293 | return 1; | 296 | *nvecs += 1; |
297 | *nbytes += sizeof(struct xfs_qoff_logitem); | ||
294 | } | 298 | } |
295 | 299 | ||
296 | /* | 300 | /* |
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 452920a3f03f..dc53e8febbbe 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c | |||
@@ -73,11 +73,22 @@ __xfs_efi_release( | |||
73 | * We only need 1 iovec for an efi item. It just logs the efi_log_format | 73 | * We only need 1 iovec for an efi item. It just logs the efi_log_format |
74 | * structure. | 74 | * structure. |
75 | */ | 75 | */ |
76 | STATIC uint | 76 | static inline int |
77 | xfs_efi_item_sizeof( | ||
78 | struct xfs_efi_log_item *efip) | ||
79 | { | ||
80 | return sizeof(struct xfs_efi_log_format) + | ||
81 | (efip->efi_format.efi_nextents - 1) * sizeof(xfs_extent_t); | ||
82 | } | ||
83 | |||
84 | STATIC void | ||
77 | xfs_efi_item_size( | 85 | xfs_efi_item_size( |
78 | struct xfs_log_item *lip) | 86 | struct xfs_log_item *lip, |
87 | int *nvecs, | ||
88 | int *nbytes) | ||
79 | { | 89 | { |
80 | return 1; | 90 | *nvecs += 1; |
91 | *nbytes += xfs_efi_item_sizeof(EFI_ITEM(lip)); | ||
81 | } | 92 | } |
82 | 93 | ||
83 | /* | 94 | /* |
@@ -93,21 +104,17 @@ xfs_efi_item_format( | |||
93 | struct xfs_log_iovec *log_vector) | 104 | struct xfs_log_iovec *log_vector) |
94 | { | 105 | { |
95 | struct xfs_efi_log_item *efip = EFI_ITEM(lip); | 106 | struct xfs_efi_log_item *efip = EFI_ITEM(lip); |
96 | uint size; | ||
97 | 107 | ||
98 | ASSERT(atomic_read(&efip->efi_next_extent) == | 108 | ASSERT(atomic_read(&efip->efi_next_extent) == |
99 | efip->efi_format.efi_nextents); | 109 | efip->efi_format.efi_nextents); |
100 | 110 | ||
101 | efip->efi_format.efi_type = XFS_LI_EFI; | 111 | efip->efi_format.efi_type = XFS_LI_EFI; |
102 | |||
103 | size = sizeof(xfs_efi_log_format_t); | ||
104 | size += (efip->efi_format.efi_nextents - 1) * sizeof(xfs_extent_t); | ||
105 | efip->efi_format.efi_size = 1; | 112 | efip->efi_format.efi_size = 1; |
106 | 113 | ||
107 | log_vector->i_addr = &efip->efi_format; | 114 | log_vector->i_addr = &efip->efi_format; |
108 | log_vector->i_len = size; | 115 | log_vector->i_len = xfs_efi_item_sizeof(efip); |
109 | log_vector->i_type = XLOG_REG_TYPE_EFI_FORMAT; | 116 | log_vector->i_type = XLOG_REG_TYPE_EFI_FORMAT; |
110 | ASSERT(size >= sizeof(xfs_efi_log_format_t)); | 117 | ASSERT(log_vector->i_len >= sizeof(xfs_efi_log_format_t)); |
111 | } | 118 | } |
112 | 119 | ||
113 | 120 | ||
@@ -333,11 +340,22 @@ xfs_efd_item_free(struct xfs_efd_log_item *efdp) | |||
333 | * We only need 1 iovec for an efd item. It just logs the efd_log_format | 340 | * We only need 1 iovec for an efd item. It just logs the efd_log_format |
334 | * structure. | 341 | * structure. |
335 | */ | 342 | */ |
336 | STATIC uint | 343 | static inline int |
344 | xfs_efd_item_sizeof( | ||
345 | struct xfs_efd_log_item *efdp) | ||
346 | { | ||
347 | return sizeof(xfs_efd_log_format_t) + | ||
348 | (efdp->efd_format.efd_nextents - 1) * sizeof(xfs_extent_t); | ||
349 | } | ||
350 | |||
351 | STATIC void | ||
337 | xfs_efd_item_size( | 352 | xfs_efd_item_size( |
338 | struct xfs_log_item *lip) | 353 | struct xfs_log_item *lip, |
354 | int *nvecs, | ||
355 | int *nbytes) | ||
339 | { | 356 | { |
340 | return 1; | 357 | *nvecs += 1; |
358 | *nbytes += xfs_efd_item_sizeof(EFD_ITEM(lip)); | ||
341 | } | 359 | } |
342 | 360 | ||
343 | /* | 361 | /* |
@@ -353,20 +371,16 @@ xfs_efd_item_format( | |||
353 | struct xfs_log_iovec *log_vector) | 371 | struct xfs_log_iovec *log_vector) |
354 | { | 372 | { |
355 | struct xfs_efd_log_item *efdp = EFD_ITEM(lip); | 373 | struct xfs_efd_log_item *efdp = EFD_ITEM(lip); |
356 | uint size; | ||
357 | 374 | ||
358 | ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents); | 375 | ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents); |
359 | 376 | ||
360 | efdp->efd_format.efd_type = XFS_LI_EFD; | 377 | efdp->efd_format.efd_type = XFS_LI_EFD; |
361 | |||
362 | size = sizeof(xfs_efd_log_format_t); | ||
363 | size += (efdp->efd_format.efd_nextents - 1) * sizeof(xfs_extent_t); | ||
364 | efdp->efd_format.efd_size = 1; | 378 | efdp->efd_format.efd_size = 1; |
365 | 379 | ||
366 | log_vector->i_addr = &efdp->efd_format; | 380 | log_vector->i_addr = &efdp->efd_format; |
367 | log_vector->i_len = size; | 381 | log_vector->i_len = xfs_efd_item_sizeof(efdp); |
368 | log_vector->i_type = XLOG_REG_TYPE_EFD_FORMAT; | 382 | log_vector->i_type = XLOG_REG_TYPE_EFD_FORMAT; |
369 | ASSERT(size >= sizeof(xfs_efd_log_format_t)); | 383 | ASSERT(log_vector->i_len >= sizeof(xfs_efd_log_format_t)); |
370 | } | 384 | } |
371 | 385 | ||
372 | /* | 386 | /* |
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c index 441a78a89901..5a5a593994d4 100644 --- a/fs/xfs/xfs_icreate_item.c +++ b/fs/xfs/xfs_icreate_item.c | |||
@@ -40,11 +40,14 @@ static inline struct xfs_icreate_item *ICR_ITEM(struct xfs_log_item *lip) | |||
40 | * | 40 | * |
41 | * We only need one iovec for the icreate log structure. | 41 | * We only need one iovec for the icreate log structure. |
42 | */ | 42 | */ |
43 | STATIC uint | 43 | STATIC void |
44 | xfs_icreate_item_size( | 44 | xfs_icreate_item_size( |
45 | struct xfs_log_item *lip) | 45 | struct xfs_log_item *lip, |
46 | int *nvecs, | ||
47 | int *nbytes) | ||
46 | { | 48 | { |
47 | return 1; | 49 | *nvecs += 1; |
50 | *nbytes += sizeof(struct xfs_icreate_log); | ||
48 | } | 51 | } |
49 | 52 | ||
50 | /* | 53 | /* |
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index f76ff52e43c0..378081109844 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c | |||
@@ -47,32 +47,44 @@ static inline struct xfs_inode_log_item *INODE_ITEM(struct xfs_log_item *lip) | |||
47 | * inode core, and possibly one for the inode data/extents/b-tree root | 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. | 48 | * and one for the inode attribute data/extents/b-tree root. |
49 | */ | 49 | */ |
50 | STATIC uint | 50 | STATIC void |
51 | xfs_inode_item_size( | 51 | xfs_inode_item_size( |
52 | struct xfs_log_item *lip) | 52 | struct xfs_log_item *lip, |
53 | int *nvecs, | ||
54 | int *nbytes) | ||
53 | { | 55 | { |
54 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); | 56 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); |
55 | struct xfs_inode *ip = iip->ili_inode; | 57 | struct xfs_inode *ip = iip->ili_inode; |
56 | uint nvecs = 2; | 58 | |
59 | *nvecs += 2; | ||
60 | *nbytes += sizeof(struct xfs_inode_log_format) + | ||
61 | xfs_icdinode_size(ip->i_d.di_version); | ||
57 | 62 | ||
58 | switch (ip->i_d.di_format) { | 63 | switch (ip->i_d.di_format) { |
59 | case XFS_DINODE_FMT_EXTENTS: | 64 | case XFS_DINODE_FMT_EXTENTS: |
60 | if ((iip->ili_fields & XFS_ILOG_DEXT) && | 65 | if ((iip->ili_fields & XFS_ILOG_DEXT) && |
61 | ip->i_d.di_nextents > 0 && | 66 | ip->i_d.di_nextents > 0 && |
62 | ip->i_df.if_bytes > 0) | 67 | ip->i_df.if_bytes > 0) { |
63 | nvecs++; | 68 | /* worst case, doesn't subtract delalloc extents */ |
69 | *nbytes += XFS_IFORK_DSIZE(ip); | ||
70 | *nvecs += 1; | ||
71 | } | ||
64 | break; | 72 | break; |
65 | 73 | ||
66 | case XFS_DINODE_FMT_BTREE: | 74 | case XFS_DINODE_FMT_BTREE: |
67 | if ((iip->ili_fields & XFS_ILOG_DBROOT) && | 75 | if ((iip->ili_fields & XFS_ILOG_DBROOT) && |
68 | ip->i_df.if_broot_bytes > 0) | 76 | ip->i_df.if_broot_bytes > 0) { |
69 | nvecs++; | 77 | *nbytes += ip->i_df.if_broot_bytes; |
78 | *nvecs += 1; | ||
79 | } | ||
70 | break; | 80 | break; |
71 | 81 | ||
72 | case XFS_DINODE_FMT_LOCAL: | 82 | case XFS_DINODE_FMT_LOCAL: |
73 | if ((iip->ili_fields & XFS_ILOG_DDATA) && | 83 | if ((iip->ili_fields & XFS_ILOG_DDATA) && |
74 | ip->i_df.if_bytes > 0) | 84 | ip->i_df.if_bytes > 0) { |
75 | nvecs++; | 85 | *nbytes += roundup(ip->i_df.if_bytes, 4); |
86 | *nvecs += 1; | ||
87 | } | ||
76 | break; | 88 | break; |
77 | 89 | ||
78 | case XFS_DINODE_FMT_DEV: | 90 | case XFS_DINODE_FMT_DEV: |
@@ -85,7 +97,7 @@ xfs_inode_item_size( | |||
85 | } | 97 | } |
86 | 98 | ||
87 | if (!XFS_IFORK_Q(ip)) | 99 | if (!XFS_IFORK_Q(ip)) |
88 | return nvecs; | 100 | return; |
89 | 101 | ||
90 | 102 | ||
91 | /* | 103 | /* |
@@ -95,28 +107,33 @@ xfs_inode_item_size( | |||
95 | case XFS_DINODE_FMT_EXTENTS: | 107 | case XFS_DINODE_FMT_EXTENTS: |
96 | if ((iip->ili_fields & XFS_ILOG_AEXT) && | 108 | if ((iip->ili_fields & XFS_ILOG_AEXT) && |
97 | ip->i_d.di_anextents > 0 && | 109 | ip->i_d.di_anextents > 0 && |
98 | ip->i_afp->if_bytes > 0) | 110 | ip->i_afp->if_bytes > 0) { |
99 | nvecs++; | 111 | /* worst case, doesn't subtract unused space */ |
112 | *nbytes += XFS_IFORK_ASIZE(ip); | ||
113 | *nvecs += 1; | ||
114 | } | ||
100 | break; | 115 | break; |
101 | 116 | ||
102 | case XFS_DINODE_FMT_BTREE: | 117 | case XFS_DINODE_FMT_BTREE: |
103 | if ((iip->ili_fields & XFS_ILOG_ABROOT) && | 118 | if ((iip->ili_fields & XFS_ILOG_ABROOT) && |
104 | ip->i_afp->if_broot_bytes > 0) | 119 | ip->i_afp->if_broot_bytes > 0) { |
105 | nvecs++; | 120 | *nbytes += ip->i_afp->if_broot_bytes; |
121 | *nvecs += 1; | ||
122 | } | ||
106 | break; | 123 | break; |
107 | 124 | ||
108 | case XFS_DINODE_FMT_LOCAL: | 125 | case XFS_DINODE_FMT_LOCAL: |
109 | if ((iip->ili_fields & XFS_ILOG_ADATA) && | 126 | if ((iip->ili_fields & XFS_ILOG_ADATA) && |
110 | ip->i_afp->if_bytes > 0) | 127 | ip->i_afp->if_bytes > 0) { |
111 | nvecs++; | 128 | *nbytes += roundup(ip->i_afp->if_bytes, 4); |
129 | *nvecs += 1; | ||
130 | } | ||
112 | break; | 131 | break; |
113 | 132 | ||
114 | default: | 133 | default: |
115 | ASSERT(0); | 134 | ASSERT(0); |
116 | break; | 135 | break; |
117 | } | 136 | } |
118 | |||
119 | return nvecs; | ||
120 | } | 137 | } |
121 | 138 | ||
122 | /* | 139 | /* |
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 02b9cf3f8252..4e108720a789 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c | |||
@@ -122,19 +122,23 @@ xlog_cil_prepare_log_vecs( | |||
122 | } | 122 | } |
123 | 123 | ||
124 | list_for_each_entry(lidp, &tp->t_items, lid_trans) { | 124 | list_for_each_entry(lidp, &tp->t_items, lid_trans) { |
125 | struct xfs_log_item *lip = lidp->lid_item; | ||
125 | struct xfs_log_vec *new_lv; | 126 | struct xfs_log_vec *new_lv; |
126 | void *ptr; | 127 | void *ptr; |
127 | int index; | 128 | int index; |
128 | int len = 0; | 129 | int len = 0; |
129 | uint niovecs; | 130 | uint niovecs = 0; |
131 | uint nbytes = 0; | ||
130 | bool ordered = false; | 132 | bool ordered = false; |
131 | 133 | ||
132 | /* Skip items which aren't dirty in this transaction. */ | 134 | /* Skip items which aren't dirty in this transaction. */ |
133 | if (!(lidp->lid_flags & XFS_LID_DIRTY)) | 135 | if (!(lidp->lid_flags & XFS_LID_DIRTY)) |
134 | continue; | 136 | continue; |
135 | 137 | ||
138 | /* get number of vecs and size of data to be stored */ | ||
139 | lip->li_ops->iop_size(lip, &niovecs, &nbytes); | ||
140 | |||
136 | /* Skip items that do not have any vectors for writing */ | 141 | /* Skip items that do not have any vectors for writing */ |
137 | niovecs = IOP_SIZE(lidp->lid_item); | ||
138 | if (!niovecs) | 142 | if (!niovecs) |
139 | continue; | 143 | continue; |
140 | 144 | ||
@@ -152,7 +156,7 @@ xlog_cil_prepare_log_vecs( | |||
152 | niovecs * sizeof(struct xfs_log_iovec), | 156 | niovecs * sizeof(struct xfs_log_iovec), |
153 | KM_SLEEP|KM_NOFS); | 157 | KM_SLEEP|KM_NOFS); |
154 | 158 | ||
155 | new_lv->lv_item = lidp->lid_item; | 159 | new_lv->lv_item = lip; |
156 | new_lv->lv_niovecs = niovecs; | 160 | new_lv->lv_niovecs = niovecs; |
157 | if (ordered) { | 161 | if (ordered) { |
158 | /* track as an ordered logvec */ | 162 | /* track as an ordered logvec */ |
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 7eb81ccd826d..97144ec230e2 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h | |||
@@ -67,7 +67,7 @@ typedef struct xfs_log_item { | |||
67 | { XFS_LI_ABORTED, "ABORTED" } | 67 | { XFS_LI_ABORTED, "ABORTED" } |
68 | 68 | ||
69 | struct xfs_item_ops { | 69 | struct xfs_item_ops { |
70 | uint (*iop_size)(xfs_log_item_t *); | 70 | void (*iop_size)(xfs_log_item_t *, int *, int *); |
71 | void (*iop_format)(xfs_log_item_t *, struct xfs_log_iovec *); | 71 | void (*iop_format)(xfs_log_item_t *, struct xfs_log_iovec *); |
72 | void (*iop_pin)(xfs_log_item_t *); | 72 | void (*iop_pin)(xfs_log_item_t *); |
73 | void (*iop_unpin)(xfs_log_item_t *, int remove); | 73 | void (*iop_unpin)(xfs_log_item_t *, int remove); |
@@ -77,7 +77,6 @@ struct xfs_item_ops { | |||
77 | void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t); | 77 | void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t); |
78 | }; | 78 | }; |
79 | 79 | ||
80 | #define IOP_SIZE(ip) (*(ip)->li_ops->iop_size)(ip) | ||
81 | #define IOP_FORMAT(ip,vp) (*(ip)->li_ops->iop_format)(ip, vp) | 80 | #define IOP_FORMAT(ip,vp) (*(ip)->li_ops->iop_format)(ip, vp) |
82 | #define IOP_PIN(ip) (*(ip)->li_ops->iop_pin)(ip) | 81 | #define IOP_PIN(ip) (*(ip)->li_ops->iop_pin)(ip) |
83 | #define IOP_UNPIN(ip, remove) (*(ip)->li_ops->iop_unpin)(ip, remove) | 82 | #define IOP_UNPIN(ip, remove) (*(ip)->li_ops->iop_unpin)(ip, remove) |