From e41191579f7330b93d0a35c175a804423c5c60e5 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 16 Apr 2015 15:25:15 +0200 Subject: [PATCH hurd 14/16] libdiskfs: xxx lookup context * ext2fs/inode.c * libdiskfs/diskfs.h * libdiskfs/node-cache.c --- ext2fs/inode.c | 6 +++--- libdiskfs/diskfs.h | 11 +++++++++-- libdiskfs/node-cache.c | 17 +++++++++++++---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/ext2fs/inode.c b/ext2fs/inode.c index ee190fa..93d686a 100644 --- a/ext2fs/inode.c +++ b/ext2fs/inode.c @@ -43,7 +43,7 @@ pthread_spinlock_t generation_lock = PTHREAD_SPINLOCK_INITIALIZER; /* XXX */ error_t -diskfs_user_make_node (struct node **npp) +diskfs_user_make_node (struct node **npp, struct lookup_context *ctx) { struct node *np; struct disknode *dn; @@ -105,7 +105,7 @@ diskfs_new_hardrefs (struct node *np) /* Read stat information out of the ext2_inode. */ error_t -diskfs_user_read_node (struct node *np) +diskfs_user_read_node (struct node *np, struct lookup_context *ctx) { error_t err; struct stat *st = &np->dn_stat; @@ -456,7 +456,7 @@ diskfs_node_reload (struct node *node) } pokel_flush (&dn->indir_pokel); flush_node_pager (node); - diskfs_user_read_node (node); + diskfs_user_read_node (node, NULL); return 0; } diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h index 22c4aa6..f7872ff 100644 --- a/libdiskfs/diskfs.h +++ b/libdiskfs/diskfs.h @@ -1106,10 +1106,14 @@ struct store *diskfs_init_main (struct argp *startup_argp, void diskfs_console_stdio (); //XXX + +/* XXX */ +struct lookup_context; + /* XXX */ -error_t diskfs_user_make_node (struct node **npp); +error_t diskfs_user_make_node (struct node **npp, struct lookup_context *ctx); /* Read stat information out of the ext2_inode. */ -error_t diskfs_user_read_node (struct node *np); +error_t diskfs_user_read_node (struct node *np, struct lookup_context *ctx); /* The last hard reference to a node has gone away; arrange to have all the weak references dropped that can be. */ void diskfs_user_try_dropping_softrefs (struct node *np); @@ -1118,5 +1122,8 @@ void diskfs_user_try_dropping_softrefs (struct node *np); without allocating any new references. */ struct node *diskfs_cached_ifind (ino_t inum); +error_t diskfs_cached_lookup_context (ino_t inum, struct node **npp, + struct lookup_context *ctx); + #endif /* hurd/diskfs.h */ diff --git a/libdiskfs/node-cache.c b/libdiskfs/node-cache.c index 58249bf..bad2bac 100644 --- a/libdiskfs/node-cache.c +++ b/libdiskfs/node-cache.c @@ -62,6 +62,15 @@ lookup (ino_t inum) error_t __attribute__ ((weak)) diskfs_cached_lookup (ino_t inum, struct node **npp) { + return diskfs_cached_lookup_context (inum, npp, NULL); +} + +/* Fetch inode INUM, set *NPP to the node structure; + gain one user reference and lock the node. */ +error_t +diskfs_cached_lookup_context (ino_t inum, struct node **npp, + struct lookup_context *ctx) +{ error_t err; struct node *np, *tmp; @@ -71,7 +80,7 @@ diskfs_cached_lookup (ino_t inum, struct node **npp) goto gotit; pthread_rwlock_unlock (&nodecache_lock); - err = diskfs_user_make_node (&np); + err = diskfs_user_make_node (&np, ctx); if (err) return err; @@ -99,7 +108,7 @@ diskfs_cached_lookup (ino_t inum, struct node **npp) pthread_rwlock_unlock (&nodecache_lock); /* Get the contents of NP off disk. */ - err = diskfs_user_read_node (np); + err = diskfs_user_read_node (np, ctx); if (err) return err; else @@ -227,14 +236,14 @@ diskfs_node_iterate (error_t (*fun)(struct node *)) /* XXX */ error_t __attribute__ ((weak)) -diskfs_user_make_node (struct node **npp) +diskfs_user_make_node (struct node **npp, struct lookup_context *ctx) { assert (! "diskfs_user_make_node not implemented"); } /* Read stat information out of the ext2_inode. */ error_t __attribute__ ((weak)) -diskfs_user_read_node (struct node *np) +diskfs_user_read_node (struct node *np, struct lookup_context *ctx) { assert (! "diskfs_user_read_node not implemented"); } -- 2.1.4