Don't return type from host in readdir on local 9p filesystem
From: Bastian Blank <[email protected]>
When using mapped mode in 9pfs, readdir implementation should not return file type in d_type from the host readdir, instead, it should use the type stored in the extended attributes. Since d_type is optional and reading ext attrs for every readdir is expensive, it should be sufficient to just set d_type to DT_UNKNOWN, so guest will know to look it up separately.
This is a -stable material.
hw/9pfs/virtio-9p-local.c +5 -1
@@ -396,12 +396,16 @@ static int local_readdir_r(FsContext *ct again: ret =readdir_r (fs->dir, entry, result); -if (ctx->export_flags &V9FS_SM_MAPPED_FILE ) { +if (ctx->export_flags &V9FS_SM_MAPPED ) { + entry->d_type =DT_UNKNOWN ; + } +else if (ctx->export_flags &V9FS_SM_MAPPED_FILE ) {if (!ret && *result !=NULL && !strcmp (entry->d_name,VIRTFS_META_DIR )) {/* skp the meta data directory */ goto again; } + entry->d_type =DT_UNKNOWN ; }return ret; }
Quoted 24 lines · Michael Tokarev
From: Bastian Blank <[email protected]>
When using mapped mode in 9pfs, readdir implementation should not return file type in
d_typefrom the host readdir, instead, it should use the type stored in the extended attributes. Sinced_typeis optional and reading ext attrs for every readdir is expensive, it should be sufficient to just setd_typetoDT_UNKNOWN, so guest will know to look it up separately.This is a -stable material.
Signed-off-by Michael Tokarev <[email protected]>hw/9pfs/virtio-9p-local.c +3
-1@@ -396,12 +396,16 @@ static int local_readdir_r(FsContext *ct again: ret =readdir_r (fs->dir, entry, result); -if (ctx->export_flags &V9FS_SM_MAPPED_FILE ) { +if (ctx->export_flags &V9FS_SM_MAPPED ) { + entry->d_type =DT_UNKNOWN ; + }
hw/9pfs/virtio-9p-local.c static int local_readdir_r(FsContext *ct · line 411
Quoted 10 lines
hw/9pfs/virtio-9p-local.c +2
-0+else if (ctx->export_flags &V9FS_SM_MAPPED_FILE ) {if (!ret && *result !=NULL && !strcmp (entry->d_name,VIRTFS_META_DIR )) {/* skp the meta data directory */ goto again; } + entry->d_type =DT_UNKNOWN ; }return ret; }
Hi Bastian,
Can I add your signed-off-by to this patch ?
-aneesh
Quoted 11 lines · Aneesh Kumar K.V
Quoted 10 lines · Michael Tokarev
From: Bastian Blank <[email protected]>
When using mapped mode in 9pfs, readdir implementation should not return file type in
d_typefrom the host readdir, instead, it should use the type stored in the extended attributes. Sinced_typeis optional and reading ext attrs for every readdir is expensive, it should be sufficient to just setd_typetoDT_UNKNOWN, so guest will know to look it up separately.
Quoted 3 lines
Quoted 3 lines
This is a -stable material.
Signed-off-by Michael Tokarev <[email protected]>
Quoted 15 lines
Quoted 15 lines
hw/9pfs/virtio-9p-local.c +4
-1@@ -396,12 +396,16 @@ static int local_readdir_r(FsContext *ct again: ret =readdir_r (fs->dir, entry, result); -if (ctx->export_flags &V9FS_SM_MAPPED_FILE ) { +if (ctx->export_flags &V9FS_SM_MAPPED ) { + entry->d_type =DT_UNKNOWN ; + } +else if (ctx->export_flags &V9FS_SM_MAPPED_FILE ) {if (!ret && *result !=NULL && !strcmp (entry->d_name,VIRTFS_META_DIR )) {/* skp the meta data directory */
Quoted 8 lines
hw/9pfs/virtio-9p-local.c static int local_readdir_r(FsContext *ct · line 411
Quoted 6 lines
hw/9pfs/virtio-9p-local.c +1
-0goto again; } + entry->d_type =DT_UNKNOWN ; }return ret; }Can I add your signed-off-by to this patch ?
Sure.
Bastian