xfs_repair fails with corrupt dinode 17491441757, extent total = 1, nblocks = 0. This is a bug.
Christoph Hellwig
hch at infradead.org
Thu Nov 3 06:54:29 CDT 2011
Can you give this patch a quick try on the image in that constrained
setup?
-------------- next part --------------
Index: xfsprogs-dev/libxfs/linux.c
===================================================================
--- xfsprogs-dev.orig/libxfs/linux.c 2011-11-03 12:01:14.213689743 +0100
+++ xfsprogs-dev/libxfs/linux.c 2011-11-03 12:46:56.928191650 +0100
@@ -207,8 +207,13 @@ platform_nproc(void)
return sysconf(_SC_NPROCESSORS_ONLN);
}
+/*
+ * Return the memory that we can use freely.
+ *
+ * The return value is in kilobytes.
+ */
unsigned long
-platform_physmem(void)
+platform_freemem(void)
{
struct sysinfo si;
@@ -217,5 +222,14 @@ platform_physmem(void)
progname);
exit(1);
}
- return (si.totalram >> 10) * si.mem_unit; /* kilobytes */
+
+ /*
+ * Assume we can use memory that is marked free. This is a very
+ * conservative approximation given that there might be a lot of
+ * pagecache that is easily reclaimable, but the only way to figure
+ * out pagecache size is by parsing /proc/meminfo, and the format
+ * of that file keeps changing. This approach is still better than
+ * guessing based on si.totalram which might be highly overestimated.
+ */
+ return (si.freeram >> 10) * si.mem_unit;
}
Index: xfsprogs-dev/include/libxfs.h
===================================================================
--- xfsprogs-dev.orig/include/libxfs.h 2011-11-03 12:29:02.001691672 +0100
+++ xfsprogs-dev/include/libxfs.h 2011-11-03 12:31:49.780691838 +0100
@@ -475,7 +475,7 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE
#define LIBXFS_BBTOOFF64(bbs) (((xfs_off_t)(bbs)) << BBSHIFT)
extern int libxfs_nproc(void);
-extern unsigned long libxfs_physmem(void); /* in kilobytes */
+extern unsigned long libxfs_freemem(void); /* in kilobytes */
#include <xfs/xfs_ialloc.h>
#include <xfs/xfs_rtalloc.h>
Index: xfsprogs-dev/libxfs/darwin.c
===================================================================
--- xfsprogs-dev.orig/libxfs/darwin.c 2011-11-03 12:29:02.017691106 +0100
+++ xfsprogs-dev/libxfs/darwin.c 2011-11-03 12:40:10.720691752 +0100
@@ -128,18 +128,27 @@ platform_nproc(void)
return ncpu;
}
+/*
+ * Return the memory that we can use freely.
+ *
+ * The return value is in kilobytes.
+ */
unsigned long
-platform_physmem(void)
+platform_freemem(void)
{
- unsigned long physmem;
- size_t len = sizeof(physmem);
+ unsigned long freemem;
+ size_t len = sizeof(freemem);
static int mib[2] = {CTL_HW, HW_PHYSMEM};
- if (sysctl(mib, 2, &physmem, &len, NULL, 0) < 0) {
+ if (sysctl(mib, 2, &freemem, &len, NULL, 0) < 0) {
fprintf(stderr, _("%s: can't determine memory size\n"),
progname);
exit(1);
}
- return physmem >> 10;
+
+ /*
+ * Assume we can use approximately 3/4 of the physical memory.
+ */
+ return (freemem >> (10 + 2)) * 3;
}
Index: xfsprogs-dev/libxfs/freebsd.c
===================================================================
--- xfsprogs-dev.orig/libxfs/freebsd.c 2011-11-03 12:29:02.037693919 +0100
+++ xfsprogs-dev/libxfs/freebsd.c 2011-11-03 12:40:19.000190942 +0100
@@ -187,17 +187,26 @@ platform_nproc(void)
return ncpu;
}
+/*
+ * Return the memory that we can use freely.
+ *
+ * The return value is in kilobytes.
+ */
unsigned long
-platform_physmem(void)
+platform_freemem(void)
{
- unsigned long physmem;
- size_t len = sizeof(physmem);
+ unsigned long freemem;
+ size_t len = sizeof(freemem);
static int mib[2] = {CTL_HW, HW_PHYSMEM};
- if (sysctl(mib, 2, &physmem, &len, NULL, 0) < 0) {
+ if (sysctl(mib, 2, &freemem, &len, NULL, 0) < 0) {
fprintf(stderr, _("%s: can't determine memory size\n"),
progname);
exit(1);
}
- return physmem >> 10;
+
+ /*
+ * Assume we can use approximately 3/4 of the physical memory.
+ */
+ return (freemem >> (10 + 2)) * 3;
}
Index: xfsprogs-dev/libxfs/init.c
===================================================================
--- xfsprogs-dev.orig/libxfs/init.c 2011-11-03 12:29:02.057690208 +0100
+++ xfsprogs-dev/libxfs/init.c 2011-11-03 12:29:50.044192568 +0100
@@ -862,7 +862,7 @@ libxfs_nproc(void)
}
unsigned long
-libxfs_physmem(void)
+libxfs_freemem(void)
{
- return platform_physmem();
+ return platform_freemem();
}
Index: xfsprogs-dev/libxfs/init.h
===================================================================
--- xfsprogs-dev.orig/libxfs/init.h 2011-11-03 12:29:02.077690698 +0100
+++ xfsprogs-dev/libxfs/init.h 2011-11-03 12:29:52.296691230 +0100
@@ -32,7 +32,7 @@ extern char *platform_findblockpath (cha
extern int platform_direct_blockdev (void);
extern int platform_align_blockdev (void);
extern int platform_nproc(void);
-extern unsigned long platform_physmem(void); /* in kilobytes */
+extern unsigned long platform_freemem(void); /* in kilobytes */
extern int platform_has_uuid;
#endif /* LIBXFS_INIT_H */
Index: xfsprogs-dev/libxfs/irix.c
===================================================================
--- xfsprogs-dev.orig/libxfs/irix.c 2011-11-03 12:29:02.097691363 +0100
+++ xfsprogs-dev/libxfs/irix.c 2011-11-03 12:42:59.724691783 +0100
@@ -97,8 +97,13 @@ platform_nproc(void)
return sysmp(MP_NPROCS);
}
+/*
+ * Return the memory that we can use freely.
+ *
+ * The return value is in kilobytes.
+ */
unsigned long
-platform_physmem(void)
+platform_freemem(void)
{
struct rminfo ri;
@@ -107,5 +112,9 @@ platform_physmem(void)
progname);
exit(1);
}
- return (ri.physmem >> 10) * getpagesize(); /* kilobytes */
-}
\ No newline at end of file
+
+ /*
+ * Assume we can use all free memory.
+ */
+ return (ri.freemem >> 10) * getpagesize(); /* kilobytes */
+}
Index: xfsprogs-dev/repair/xfs_repair.c
===================================================================
--- xfsprogs-dev.orig/repair/xfs_repair.c 2011-11-03 12:29:02.117690613 +0100
+++ xfsprogs-dev/repair/xfs_repair.c 2011-11-03 12:32:42.348190446 +0100
@@ -631,8 +631,11 @@ main(int argc, char **argv)
mem_used = (mp->m_sb.sb_icount >> (10 - 2)) +
(mp->m_sb.sb_dblocks >> (10 + 1)) +
50000; /* rough estimate of 50MB overhead */
- max_mem = max_mem_specified ? max_mem_specified * 1024 :
- libxfs_physmem() * 3 / 4;
+
+ if (max_mem_specified)
+ max_mem = max_mem_specified * 1024;
+ else
+ max_mem = libxfs_freemem();
if (getrlimit(RLIMIT_AS, &rlim) != -1 &&
rlim.rlim_cur != RLIM_INFINITY) {
More information about the xfs
mailing list