* [PATCH 2/7] xfs: fix min bufsize bugs in two places
@ 2010-03-18 22:53 Alex Elder
2010-03-20 16:42 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Alex Elder @ 2010-03-18 22:53 UTC (permalink / raw)
To: xfs
This fixes a bug in two places that I found by inspection. In
xlog_find_verify_cycle() and xlog_write_log_records(), the code
attempts to allocate a buffer to hold as many blocks as possible.
It gives up if the number of blocks to be allocated gets too small.
Right now it uses log->l_sectbb_log as that lower bound, but I'm
sure it's supposed to be the actual log sector size instead. That
is, the lower bound should be (1 << log->l_sectbb_log).
Also define a simple macro xlog_sectbb(log) to represent the number
of basic blocks in a sector for the given log.
Signed-off-by: Alex Elder <aelder@sgi.com>
---
fs/xfs/xfs_log_recover.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
Index: b/fs/xfs/xfs_log_recover.c
===================================================================
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -66,6 +66,9 @@ STATIC void xlog_recover_check_summary(x
((bbs + (log)->l_sectbb_mask + 1) & ~(log)->l_sectbb_mask) : (bbs) )
#define XLOG_SECTOR_ROUNDDOWN_BLKNO(log, bno) ((bno) & ~(log)->l_sectbb_mask)
+/* Number of basic blocks in a log sector */
+#define xlog_sectbb(log) (1 << (log)->l_sectbb_log)
+
STATIC xfs_buf_t *
xlog_get_bp(
xlog_t *log,
@@ -376,12 +379,16 @@ xlog_find_verify_cycle(
xfs_caddr_t buf = NULL;
int error = 0;
+ /*
+ * Greedily allocate a buffer big enough to handle the full
+ * range of basic blocks we'll be examining. If that fails,
+ * try a smaller size. We need to be able to read at least
+ * a log sector, or we're out of luck.
+ */
bufblks = 1 << ffs(nbblks);
-
while (!(bp = xlog_get_bp(log, bufblks))) {
- /* can't get enough memory to do everything in one big buffer */
bufblks >>= 1;
- if (bufblks <= log->l_sectbb_log)
+ if (bufblks < xlog_sectbb(log))
return ENOMEM;
}
@@ -1158,10 +1165,16 @@ xlog_write_log_records(
int error = 0;
int i, j = 0;
+ /*
+ * Greedily allocate a buffer big enough to handle the full
+ * range of basic blocks to be written. If that fails, try
+ * a smaller size. We need to be able to write at least a
+ * log sector, or we're out of luck.
+ */
bufblks = 1 << ffs(blocks);
while (!(bp = xlog_get_bp(log, bufblks))) {
bufblks >>= 1;
- if (bufblks <= log->l_sectbb_log)
+ if (bufblks < xlog_sectbb(log))
return ENOMEM;
}
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/7] xfs: fix min bufsize bugs in two places
2010-03-18 22:53 [PATCH 2/7] xfs: fix min bufsize bugs in two places Alex Elder
@ 2010-03-20 16:42 ` Christoph Hellwig
2010-03-25 14:23 ` Alex Elder
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2010-03-20 16:42 UTC (permalink / raw)
To: Alex Elder; +Cc: xfs
> +/* Number of basic blocks in a log sector */
> +#define xlog_sectbb(log) (1 << (log)->l_sectbb_log)
Looking at all uses of (log)->l_sectbb_log I wonder if we should
bother storing this in the log structure in this form, or rather
as the multipler of the basic block size, ala l_sectsize. All the
if (log->l_sectbb_log) {
checks would just become
if (log->l_sectsize > 1) {
and the xlog_find_verify_cycle/xlog_write_log_records checks
would also be a natural
if (bufblks < log->l_sectsize)
The comments added are defintively useful, btw.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/7] xfs: fix min bufsize bugs in two places
2010-03-20 16:42 ` Christoph Hellwig
@ 2010-03-25 14:23 ` Alex Elder
0 siblings, 0 replies; 3+ messages in thread
From: Alex Elder @ 2010-03-25 14:23 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
On Sat, 2010-03-20 at 12:42 -0400, Christoph Hellwig wrote:
> > +/* Number of basic blocks in a log sector */
> > +#define xlog_sectbb(log) (1 << (log)->l_sectbb_log)
>
> Looking at all uses of (log)->l_sectbb_log I wonder if we should
> bother storing this in the log structure in this form, or rather
> as the multipler of the basic block size, ala l_sectsize. All the
I agree, and I was sort of headed in that direction. I have
more work in this file that eventually will lead to some larger
scale (algorithmic) simplification. But for now I'm starting
small.
> if (log->l_sectbb_log) {
>
> checks would just become
>
> if (log->l_sectsize > 1) {
>
> and the xlog_find_verify_cycle/xlog_write_log_records checks
> would also be a natural
>
> if (bufblks < log->l_sectsize)
I'll attack this in a later patch.
> The comments added are defintively useful, btw.
Thanks, I felt they were necessary. More to come.
I got "looks good" from you on all but this patch,
and numbers 5 and 7 in the series. Is this one OK,
and do you plan to review those other two?
-Alex
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-25 14:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-18 22:53 [PATCH 2/7] xfs: fix min bufsize bugs in two places Alex Elder
2010-03-20 16:42 ` Christoph Hellwig
2010-03-25 14:23 ` Alex Elder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox