diff options
author | Alex Elder <aelder@sgi.com> | 2010-04-20 03:09:59 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-05-19 10:58:15 -0400 |
commit | 69ce58f08a3c455ff74cfcde90e9ab267d67f636 (patch) | |
tree | 0a5a8be3222d8138f382b492b96888c61041dd76 /fs/xfs | |
parent | 1414a6046ab402ac21545522270c32c576327eb9 (diff) |
xfs: record log sector size rather than log2(that)
Change struct log so it keeps track of the size (in basic blocks) of
a log sector in l_sectBBsize rather than the log-base-2 of that
value (previously, l_sectbb_log). The name was chosen for
consistency with the other fields in the structure that represent
a number of basic blocks.
(Updated so that a variable used in computing and verifying a log's
sector size is named "log2_size". Also added the "BB" to the
structure field name, based on feedback from Eric Sandeen. Also
dropped some superfluous parentheses.)
Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_log.c | 33 | ||||
-rw-r--r-- | fs/xfs/xfs_log_priv.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 27 |
3 files changed, 31 insertions, 31 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 77593c2ead4d..36e09e362f7f 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -1039,6 +1039,7 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1039 | int i; | 1039 | int i; |
1040 | int iclogsize; | 1040 | int iclogsize; |
1041 | int error = ENOMEM; | 1041 | int error = ENOMEM; |
1042 | uint log2_size = 0; | ||
1042 | 1043 | ||
1043 | log = kmem_zalloc(sizeof(xlog_t), KM_MAYFAIL); | 1044 | log = kmem_zalloc(sizeof(xlog_t), KM_MAYFAIL); |
1044 | if (!log) { | 1045 | if (!log) { |
@@ -1064,29 +1065,31 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1064 | 1065 | ||
1065 | error = EFSCORRUPTED; | 1066 | error = EFSCORRUPTED; |
1066 | if (xfs_sb_version_hassector(&mp->m_sb)) { | 1067 | if (xfs_sb_version_hassector(&mp->m_sb)) { |
1067 | log->l_sectbb_log = mp->m_sb.sb_logsectlog - BBSHIFT; | 1068 | log2_size = mp->m_sb.sb_logsectlog; |
1068 | if (log->l_sectbb_log < 0 || | 1069 | if (log2_size < BBSHIFT) { |
1069 | log->l_sectbb_log > mp->m_sectbb_log) { | 1070 | xlog_warn("XFS: Log sector size too small " |
1070 | xlog_warn("XFS: Log sector size (0x%x) out of range.", | 1071 | "(0x%x < 0x%x)", log2_size, BBSHIFT); |
1071 | log->l_sectbb_log); | ||
1072 | goto out_free_log; | 1072 | goto out_free_log; |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | /* for larger sector sizes, must have v2 or external log */ | 1075 | log2_size -= BBSHIFT; |
1076 | if (log->l_sectbb_log != 0 && | 1076 | if (log2_size > mp->m_sectbb_log) { |
1077 | (log->l_logBBstart != 0 && | 1077 | xlog_warn("XFS: Log sector size too large " |
1078 | !xfs_sb_version_haslogv2(&mp->m_sb))) { | 1078 | "(0x%x > 0x%x)", log2_size, mp->m_sectbb_log); |
1079 | xlog_warn("XFS: log sector size (0x%x) invalid " | ||
1080 | "for configuration.", log->l_sectbb_log); | ||
1081 | goto out_free_log; | 1079 | goto out_free_log; |
1082 | } | 1080 | } |
1083 | if (mp->m_sb.sb_logsectlog < BBSHIFT) { | 1081 | |
1084 | xlog_warn("XFS: Log sector log (0x%x) too small.", | 1082 | /* for larger sector sizes, must have v2 or external log */ |
1085 | mp->m_sb.sb_logsectlog); | 1083 | if (log2_size && log->l_logBBstart > 0 && |
1084 | !xfs_sb_version_haslogv2(&mp->m_sb)) { | ||
1085 | |||
1086 | xlog_warn("XFS: log sector size (0x%x) invalid " | ||
1087 | "for configuration.", log2_size); | ||
1086 | goto out_free_log; | 1088 | goto out_free_log; |
1087 | } | 1089 | } |
1088 | } | 1090 | } |
1089 | log->l_sectbb_mask = (1 << log->l_sectbb_log) - 1; | 1091 | log->l_sectBBsize = 1 << log2_size; |
1092 | log->l_sectbb_mask = log->l_sectBBsize - 1; | ||
1090 | 1093 | ||
1091 | xlog_get_iclog_buffer_size(mp, log); | 1094 | xlog_get_iclog_buffer_size(mp, log); |
1092 | 1095 | ||
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 2f2b5ca2a00a..56f221d7bf61 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h | |||
@@ -396,7 +396,7 @@ typedef struct log { | |||
396 | struct xfs_buf_cancel **l_buf_cancel_table; | 396 | struct xfs_buf_cancel **l_buf_cancel_table; |
397 | int l_iclog_hsize; /* size of iclog header */ | 397 | int l_iclog_hsize; /* size of iclog header */ |
398 | int l_iclog_heads; /* # of iclog header sectors */ | 398 | int l_iclog_heads; /* # of iclog header sectors */ |
399 | uint l_sectbb_log; /* log2 of sector size in BBs */ | 399 | uint l_sectBBsize; /* sector size in BBs */ |
400 | uint l_sectbb_mask; /* sector size (in BBs) | 400 | uint l_sectbb_mask; /* sector size (in BBs) |
401 | * alignment mask */ | 401 | * alignment mask */ |
402 | int l_iclog_size; /* size of log in bytes */ | 402 | int l_iclog_size; /* size of log in bytes */ |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index e5b74db5d2e0..f1220ec1896f 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -60,9 +60,6 @@ STATIC void xlog_recover_check_summary(xlog_t *); | |||
60 | * Sector aligned buffer routines for buffer create/read/write/access | 60 | * Sector aligned buffer routines for buffer create/read/write/access |
61 | */ | 61 | */ |
62 | 62 | ||
63 | /* Number of basic blocks in a log sector */ | ||
64 | #define xlog_sectbb(log) (1 << (log)->l_sectbb_log) | ||
65 | |||
66 | /* | 63 | /* |
67 | * Verify the given count of basic blocks is valid number of blocks | 64 | * Verify the given count of basic blocks is valid number of blocks |
68 | * to specify for an operation involving the given XFS log buffer. | 65 | * to specify for an operation involving the given XFS log buffer. |
@@ -110,9 +107,9 @@ xlog_get_bp( | |||
110 | * extend the buffer by one extra log sector to ensure | 107 | * extend the buffer by one extra log sector to ensure |
111 | * there's space to accomodate this possiblility. | 108 | * there's space to accomodate this possiblility. |
112 | */ | 109 | */ |
113 | if (nbblks > 1 && log->l_sectbb_log) | 110 | if (nbblks > 1 && log->l_sectBBsize > 1) |
114 | nbblks += xlog_sectbb(log); | 111 | nbblks += log->l_sectBBsize; |
115 | nbblks = round_up(nbblks, xlog_sectbb(log)); | 112 | nbblks = round_up(nbblks, log->l_sectBBsize); |
116 | 113 | ||
117 | return xfs_buf_get_noaddr(BBTOB(nbblks), log->l_mp->m_logdev_targp); | 114 | return xfs_buf_get_noaddr(BBTOB(nbblks), log->l_mp->m_logdev_targp); |
118 | } | 115 | } |
@@ -133,7 +130,7 @@ xlog_align( | |||
133 | { | 130 | { |
134 | xfs_caddr_t ptr; | 131 | xfs_caddr_t ptr; |
135 | 132 | ||
136 | if (!log->l_sectbb_log) | 133 | if (log->l_sectBBsize == 1) |
137 | return XFS_BUF_PTR(bp); | 134 | return XFS_BUF_PTR(bp); |
138 | 135 | ||
139 | ptr = XFS_BUF_PTR(bp) + BBTOB((int)blk_no & log->l_sectbb_mask); | 136 | ptr = XFS_BUF_PTR(bp) + BBTOB((int)blk_no & log->l_sectbb_mask); |
@@ -162,8 +159,8 @@ xlog_bread_noalign( | |||
162 | return EFSCORRUPTED; | 159 | return EFSCORRUPTED; |
163 | } | 160 | } |
164 | 161 | ||
165 | blk_no = round_down(blk_no, xlog_sectbb(log)); | 162 | blk_no = round_down(blk_no, log->l_sectBBsize); |
166 | nbblks = round_up(nbblks, xlog_sectbb(log)); | 163 | nbblks = round_up(nbblks, log->l_sectBBsize); |
167 | 164 | ||
168 | ASSERT(nbblks > 0); | 165 | ASSERT(nbblks > 0); |
169 | ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp)); | 166 | ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp)); |
@@ -221,8 +218,8 @@ xlog_bwrite( | |||
221 | return EFSCORRUPTED; | 218 | return EFSCORRUPTED; |
222 | } | 219 | } |
223 | 220 | ||
224 | blk_no = round_down(blk_no, xlog_sectbb(log)); | 221 | blk_no = round_down(blk_no, log->l_sectBBsize); |
225 | nbblks = round_up(nbblks, xlog_sectbb(log)); | 222 | nbblks = round_up(nbblks, log->l_sectBBsize); |
226 | 223 | ||
227 | ASSERT(nbblks > 0); | 224 | ASSERT(nbblks > 0); |
228 | ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp)); | 225 | ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp)); |
@@ -410,7 +407,7 @@ xlog_find_verify_cycle( | |||
410 | bufblks = 1 << ffs(nbblks); | 407 | bufblks = 1 << ffs(nbblks); |
411 | while (!(bp = xlog_get_bp(log, bufblks))) { | 408 | while (!(bp = xlog_get_bp(log, bufblks))) { |
412 | bufblks >>= 1; | 409 | bufblks >>= 1; |
413 | if (bufblks < xlog_sectbb(log)) | 410 | if (bufblks < log->l_sectBBsize) |
414 | return ENOMEM; | 411 | return ENOMEM; |
415 | } | 412 | } |
416 | 413 | ||
@@ -1181,7 +1178,7 @@ xlog_write_log_records( | |||
1181 | xfs_caddr_t offset; | 1178 | xfs_caddr_t offset; |
1182 | xfs_buf_t *bp; | 1179 | xfs_buf_t *bp; |
1183 | int balign, ealign; | 1180 | int balign, ealign; |
1184 | int sectbb = xlog_sectbb(log); | 1181 | int sectbb = log->l_sectBBsize; |
1185 | int end_block = start_block + blocks; | 1182 | int end_block = start_block + blocks; |
1186 | int bufblks; | 1183 | int bufblks; |
1187 | int error = 0; | 1184 | int error = 0; |
@@ -1196,7 +1193,7 @@ xlog_write_log_records( | |||
1196 | bufblks = 1 << ffs(blocks); | 1193 | bufblks = 1 << ffs(blocks); |
1197 | while (!(bp = xlog_get_bp(log, bufblks))) { | 1194 | while (!(bp = xlog_get_bp(log, bufblks))) { |
1198 | bufblks >>= 1; | 1195 | bufblks >>= 1; |
1199 | if (bufblks < xlog_sectbb(log)) | 1196 | if (bufblks < sectbb) |
1200 | return ENOMEM; | 1197 | return ENOMEM; |
1201 | } | 1198 | } |
1202 | 1199 | ||
@@ -3515,7 +3512,7 @@ xlog_do_recovery_pass( | |||
3515 | hblks = 1; | 3512 | hblks = 1; |
3516 | } | 3513 | } |
3517 | } else { | 3514 | } else { |
3518 | ASSERT(log->l_sectbb_log == 0); | 3515 | ASSERT(log->l_sectBBsize == 1); |
3519 | hblks = 1; | 3516 | hblks = 1; |
3520 | hbp = xlog_get_bp(log, 1); | 3517 | hbp = xlog_get_bp(log, 1); |
3521 | h_size = XLOG_BIG_RECORD_BSIZE; | 3518 | h_size = XLOG_BIG_RECORD_BSIZE; |