public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] remove xattr buffer size dependency on page size in xfsdump
@ 2008-05-22  6:14 David Chinner
  2008-05-22 13:28 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: David Chinner @ 2008-05-22  6:14 UTC (permalink / raw)
  To: xfs-dev; +Cc: xfs-oss


The extended attr buffer size used by xfsdump is based on page size.
The maximum buffer size the kernel will accept is 64k. On a 64k page
machine, the default buffer size will be rejected by the kernel, thereby
breaking dump and restore.

Limit the buffer size to XATTR_LIST_MAX in dump, restore and libhandle
so the kernel won't reject otherwise valid requests.

Signed-off-by: Dave Chinner <dgc@sgi.com>
---
 xfsdump/dump/content.c      |    2 +-
 xfsprogs/libhandle/handle.c |    5 ++++-
 xfsprogs/libhandle/jdm.c    |    4 ++++
 3 files changed, 9 insertions(+), 2 deletions(-)

Index: xfs-cmds/xfsdump/dump/content.c
===================================================================
--- xfs-cmds.orig/xfsdump/dump/content.c	2007-02-03 01:26:21.000000000 +1100
+++ xfs-cmds/xfsdump/dump/content.c	2008-05-13 08:46:04.673298673 +1000
@@ -210,7 +210,7 @@ typedef struct extent_group_context exte
 
 /* minimum sizes for extended attributes buffers
  */
-#define EXTATTR_LISTBUF_SZ	( 4 * pgsz )
+#define EXTATTR_LISTBUF_SZ	( XATTR_LIST_MAX )
 #define EXTATTR_RTRVARRAY_LEN	( 1 * pgsz )
 #define EXTATTR_DUMPBUF_SZ	( 4 * pgsz )
 
Index: xfs-cmds/xfsprogs/libhandle/handle.c
===================================================================
--- xfs-cmds.orig/xfsprogs/libhandle/handle.c	2006-11-15 19:00:31.000000000 +1100
+++ xfs-cmds/xfsprogs/libhandle/handle.c	2008-05-13 08:52:07.150983837 +1000
@@ -360,8 +360,11 @@ attr_list_by_handle(
 
 	memcpy(&alhreq.pos, cursor, sizeof(alhreq.pos));
 	alhreq.flags = flags;
-	alhreq.buflen = bufsize;
 	alhreq.buffer = buf;
+	alhreq.buflen = bufsize;
+	/* prevent needless EINVAL from the kernel */
+	if (alhreq.buflen > XATTR_LIST_MAX)
+		alhreq.buflen = XATTR_LIST_MAX;
 
 	error = xfsctl(path, fd, XFS_IOC_ATTRLIST_BY_HANDLE, &alhreq);
 
Index: xfs-cmds/xfsprogs/libhandle/jdm.c
===================================================================
--- xfs-cmds.orig/xfsprogs/libhandle/jdm.c	2008-04-16 13:04:05.000000000 +1000
+++ xfs-cmds/xfsprogs/libhandle/jdm.c	2008-05-13 08:51:23.344565394 +1000
@@ -166,6 +166,10 @@ jdm_attr_list(	jdm_fshandle_t *fshp,
 	filehandle_t filehandle;
 	int rval;
 
+	/* prevent needless EINVAL from the kernel */
+	if (bufsz > XATTR_LIST_MAX)
+		bufsz = XATTR_LIST_MAX;
+
 	jdm_fill_filehandle( &filehandle, fshandlep, statp );
 	rval = attr_list_by_handle (( void * )&filehandle,
 			sizeof( filehandle ),

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] remove xattr buffer size dependency on page size in xfsdump
  2008-05-22  6:14 [patch] remove xattr buffer size dependency on page size in xfsdump David Chinner
@ 2008-05-22 13:28 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2008-05-22 13:28 UTC (permalink / raw)
  To: David Chinner; +Cc: xfs-dev, xfs-oss

On Thu, May 22, 2008 at 04:14:02PM +1000, David Chinner wrote:
> 
> The extended attr buffer size used by xfsdump is based on page size.
> The maximum buffer size the kernel will accept is 64k. On a 64k page
> machine, the default buffer size will be rejected by the kernel, thereby
> breaking dump and restore.
> 
> Limit the buffer size to XATTR_LIST_MAX in dump, restore and libhandle
> so the kernel won't reject otherwise valid requests.

I suspect this will break on non-linux platforms because XATTR_LIST_MAX
is only in the Linux headers.  With a precaution, e.g. by keeping the
old behaviour when XATTR_LIST_MAX is not defined this looks good.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-05-22 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-22  6:14 [patch] remove xattr buffer size dependency on page size in xfsdump David Chinner
2008-05-22 13:28 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox