remove xattr buffer size dependency on page size in xfsdump
PATCH 1/1 remove xattr buffer size dependency on page size in xfsdump
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.
--- xfsdump/dump/content.c | 2 +- xfsprogs/libhandle/handle.c | 5 ++++- xfsprogs/libhandle/jdm.c | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-)
xfsdump/dump/content.c +1 -1
@@ -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 )
xfsprogs/libhandle/handle.c +4 -1
@@ -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);
xfsprogs/libhandle/jdm.c +4 -0
@@ -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 ),
Quoted 8 lines · David Chinner
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_MAXin 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.