Skip to contentSkip to conversation

9p: mitigates most QID path collisions

PATCH Superseded Christian Schoenebeck 1 participant 1 message Apr 23, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 9p: mitigates most QID path collisions

I am attempting to revive Antonios Motakis' effort to fix the current file ID collisions with 9p. My patch set does not fix all the concerns you had with his original patch set, especially if there is still some (very rare) case of QID path collision the affected files are still visible on guest. However I hope we can bring this overall issue forward, because with the current 9p implementation it is almost inevitable to end up with QID path collisions, which in turn causes very severe misbehaviours like data corruption and data loss on guest.

On the other hand the yet unresolved issues that you noted are IMO rather theoretical issues. Because in practice you usually will have around not more than one or two dozens of entries in qpp_table (and not a single entry in qpf_table).

So this first patch here is an updated version of Antonios Motakis' original 4-patch set, merged to one patch:

https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg02283.html

* Updated to latest git master, specifically to new qht interface.

* Merged the original 4 patches to this single patch.

---
 fsdev/9p-marshal.h |   4 +-
 hw/9pfs/9p.c       | 200 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 hw/9pfs/9p.h       |  21 ++++++
 3 files changed, 204 insertions(+), 21 deletions(-)
fsdev/9p-marshal.h +2 -2
index c8823d878f..d1ad3645c4 100644
@@ -10,8 +10,8 @@ typedef struct V9fsString
 typedef struct V9fsQID
 {
     int8_t type;
-    int32_t version;
-    int64_t path;
+    uint32_t version;
+    uint64_t path;
 } V9fsQID;
 
 typedef struct V9fsStat
hw/9pfs/9p.c +181 -19

316 lines not on this page · raw message

hw/9pfs/9p.h +21 -0
index 8883761b2c..44112ea97f 100644
@@ -8,6 +8,7 @@
 #include "fsdev/9p-iov-marshal.h"
 #include "qemu/thread.h"
 #include "qemu/coroutine.h"
+#include "qemu/qht.h"
 
 enum {
     P9_TLERROR = 6,
@@ -235,6 +236,22 @@ struct V9fsFidState
     V9fsFidState *rclm_lst;
 };
 
+#define QPATH_INO_MASK        (((unsigned long)1 << 48) - 1)
+
+/* QID path prefix entry, see stat_to_qid */
+typedef struct {
+    dev_t dev;
+    uint16_t ino_prefix;
+    uint16_t qp_prefix;
+} QppEntry;
+
+/* QID path full entry, as above */
+typedef struct {
+    dev_t dev;
+    ino_t ino;
+    uint64_t path;
+} QpfEntry;
+
 struct V9fsState
 {
     QLIST_HEAD(, V9fsPDU) free_list;
@@ -256,6 +273,10 @@ struct V9fsState
     Error *migration_blocker;
     V9fsConf fsconf;
     V9fsQID root_qid;
+    struct qht qpp_table;
+    struct qht qpf_table;
+    uint16_t qp_prefix_next;
+    uint64_t qp_fullpath_next;
 };
 
 /* 9p2000.L open flags */
Signature · 1 line
2.11.0