commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 10/20: ext2fs: use fat nodes


From: Samuel Thibault
Subject: [hurd] 10/20: ext2fs: use fat nodes
Date: Sat, 23 May 2015 05:09:41 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit bf06e6535f7e00a3711978fa7835a3394b82b547
Author: Justus Winter <address@hidden>
Date:   Tue Apr 14 22:37:31 2015 +0200

    ext2fs: use fat nodes
    
    Use `diskfs_make_node_alloc' to allocate both the node and the
    disknode in a continuous chunk of memory.  This increases locality and
    reduces the pressure on the memory allocator.
    
    * ext2fs/inode.c: Use `diskfs_node_disknode' to access the disknode.
    (diskfs_cached_lookup): Use `diskfs_make_node_alloc' to allocate the
    node.
    (diskfs_node_norefs): Only free `np'.
    * ext2fs/dir.c: Use `diskfs_node_disknode' to access the disknode.
    * ext2fs/ext2fs.h: Likewise.
    * ext2fs/getblk.c: Likewise.
    * ext2fs/ialloc.c: Likewise.
    * ext2fs/pager.c: Likewise.
    * ext2fs/truncate.c: Likewise.
---
 ext2fs/dir.c      | 75 +++++++++++++++++++++++++++++--------------------------
 ext2fs/ext2fs.h   |  4 +--
 ext2fs/getblk.c   | 63 +++++++++++++++++++++++-----------------------
 ext2fs/ialloc.c   | 13 +++++-----
 ext2fs/inode.c    | 67 ++++++++++++++++++++++++-------------------------
 ext2fs/pager.c    | 52 +++++++++++++++++++-------------------
 ext2fs/truncate.c | 16 ++++++------
 7 files changed, 147 insertions(+), 143 deletions(-)

diff --git a/ext2fs/dir.c b/ext2fs/dir.c
index 470b7e9..2dfe1d7 100644
--- a/ext2fs/dir.c
+++ b/ext2fs/dir.c
@@ -202,8 +202,8 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum 
lookup_type type,
 
   diskfs_set_node_atime (dp);
 
-  /* Start the lookup at DP->dn->dir_idx.  */
-  idx = dp->dn->dir_idx;
+  /* Start the lookup at diskfs_node_disknode (DP)->dir_idx.  */
+  idx = diskfs_node_disknode (dp)->dir_idx;
   if (idx * DIRBLKSIZ > dp->dn_stat.st_size)
     idx = 0;                   /* just in case */
   blockaddr = buf + idx * DIRBLKSIZ;
@@ -217,7 +217,7 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum 
lookup_type type,
       err = dirscanblock (blockaddr, dp, idx, name, namelen, type, ds, &inum);
       if (!err)
        {
-         dp->dn->dir_idx = idx;
+         diskfs_node_disknode (dp)->dir_idx = idx;
          break;
        }
       if (err != ENOENT)
@@ -484,17 +484,17 @@ dirscanblock (vm_address_t blockaddr, struct node *dp, 
int idx,
 
       /* Because we scanned the entire block, we should write
         down how many entries there were. */
-      if (!dp->dn->dirents)
+      if (!diskfs_node_disknode (dp)->dirents)
        {
-         dp->dn->dirents = malloc ((dp->dn_stat.st_size / DIRBLKSIZ)
-                                   * sizeof (int));
+         diskfs_node_disknode (dp)->dirents =
+           malloc ((dp->dn_stat.st_size / DIRBLKSIZ) * sizeof (int));
          for (i = 0; i < dp->dn_stat.st_size/DIRBLKSIZ; i++)
-           dp->dn->dirents[i] = -1;
+           diskfs_node_disknode (dp)->dirents[i] = -1;
        }
       /* Make sure the count is correct if there is one now. */
-      assert (dp->dn->dirents[idx] == -1
-             || dp->dn->dirents[idx] == nentries);
-      dp->dn->dirents[idx] = nentries;
+      assert (diskfs_node_disknode (dp)->dirents[idx] == -1
+             || diskfs_node_disknode (dp)->dirents[idx] == nentries);
+      diskfs_node_disknode (dp)->dirents[idx] = nentries;
 
       return ENOENT;
     }
@@ -653,7 +653,7 @@ diskfs_direnter_hard (struct node *dp, const char *name, 
struct node *np,
   memcpy (new->name, name, namelen);
 
   /* Mark the directory inode has having been written.  */
-  dp->dn->info.i_flags &= ~EXT2_BTREE_FL;
+  diskfs_node_disknode (dp)->info.i_flags &= ~EXT2_BTREE_FL;
   dp->dn_set_mtime = 1;
 
   munmap ((caddr_t) ds->mapbuf, ds->mapextent);
@@ -662,33 +662,34 @@ diskfs_direnter_hard (struct node *dp, const char *name, 
struct node *np,
     {
       /* If we are keeping count of this block, then keep the count up
         to date. */
-      if (dp->dn->dirents && dp->dn->dirents[ds->idx] != -1)
-       dp->dn->dirents[ds->idx]++;
+      if (diskfs_node_disknode (dp)->dirents
+         && diskfs_node_disknode (dp)->dirents[ds->idx] != -1)
+       diskfs_node_disknode (dp)->dirents[ds->idx]++;
     }
   else
     {
       int i;
       /* It's cheap, so start a count here even if we aren't counting
         anything at all. */
-      if (dp->dn->dirents)
+      if (diskfs_node_disknode (dp)->dirents)
        {
-         dp->dn->dirents = realloc (dp->dn->dirents,
-                                    (dp->dn_stat.st_size / DIRBLKSIZ
-                                     * sizeof (int)));
+         diskfs_node_disknode (dp)->dirents =
+           realloc (diskfs_node_disknode (dp)->dirents,
+                    (dp->dn_stat.st_size / DIRBLKSIZ * sizeof (int)));
          for (i = oldsize / DIRBLKSIZ;
               i < dp->dn_stat.st_size / DIRBLKSIZ;
               i++)
-           dp->dn->dirents[i] = -1;
+           diskfs_node_disknode (dp)->dirents[i] = -1;
 
-         dp->dn->dirents[ds->idx] = 1;
+         diskfs_node_disknode (dp)->dirents[ds->idx] = 1;
        }
       else
        {
-         dp->dn->dirents = malloc (dp->dn_stat.st_size / DIRBLKSIZ
-                                   * sizeof (int));
+         diskfs_node_disknode (dp)->dirents =
+           malloc (dp->dn_stat.st_size / DIRBLKSIZ * sizeof (int));
          for (i = 0; i < dp->dn_stat.st_size / DIRBLKSIZ; i++)
-           dp->dn->dirents[i] = -1;
-         dp->dn->dirents[ds->idx] = 1;
+           diskfs_node_disknode (dp)->dirents[i] = -1;
+         diskfs_node_disknode (dp)->dirents[ds->idx] = 1;
        }
     }
 
@@ -720,14 +721,15 @@ diskfs_dirremove_hard (struct node *dp, struct dirstat 
*ds)
     }
 
   dp->dn_set_mtime = 1;
-  dp->dn->info.i_flags &= ~EXT2_BTREE_FL;
+  diskfs_node_disknode (dp)->info.i_flags &= ~EXT2_BTREE_FL;
 
   munmap ((caddr_t) ds->mapbuf, ds->mapextent);
 
   /* If we are keeping count of this block, then keep the count up
      to date. */
-  if (dp->dn->dirents && dp->dn->dirents[ds->idx] != -1)
-    dp->dn->dirents[ds->idx]--;
+  if (diskfs_node_disknode (dp)->dirents
+      && diskfs_node_disknode (dp)->dirents[ds->idx] != -1)
+    diskfs_node_disknode (dp)->dirents[ds->idx]--;
 
   diskfs_file_update (dp, diskfs_synchronous);
 
@@ -751,7 +753,7 @@ diskfs_dirrewrite_hard (struct node *dp, struct node *np, 
struct dirstat *ds)
 
   ds->entry->inode = np->cache_id;
   dp->dn_set_mtime = 1;
-  dp->dn->info.i_flags &= ~EXT2_BTREE_FL;
+  diskfs_node_disknode (dp)->info.i_flags &= ~EXT2_BTREE_FL;
 
   munmap ((caddr_t) ds->mapbuf, ds->mapextent);
 
@@ -831,7 +833,7 @@ count_dirents (struct node *dp, block_t nb, char *buf)
   int count = 0;
   error_t err;
 
-  assert (dp->dn->dirents);
+  assert (diskfs_node_disknode (dp)->dirents);
   assert ((nb + 1) * DIRBLKSIZ <= dp->dn_stat.st_size);
 
   err = diskfs_node_rdwr (dp, buf, nb * DIRBLKSIZ, DIRBLKSIZ, 0, 0, &amt);
@@ -848,8 +850,9 @@ count_dirents (struct node *dp, block_t nb, char *buf)
        count++;
     }
 
-  assert (dp->dn->dirents[nb] == -1 || dp->dn->dirents[nb] == count);
-  dp->dn->dirents[nb] = count;
+  assert (diskfs_node_disknode (dp)->dirents[nb] == -1
+         || diskfs_node_disknode (dp)->dirents[nb] == count);
+  diskfs_node_disknode (dp)->dirents[nb] = count;
   return 0;
 }
 
@@ -884,11 +887,11 @@ diskfs_get_directs (struct node *dp,
 
   nblks = dp->dn_stat.st_size/DIRBLKSIZ;
 
-  if (!dp->dn->dirents)
+  if (!diskfs_node_disknode (dp)->dirents)
     {
-      dp->dn->dirents = malloc (nblks * sizeof (int));
+      diskfs_node_disknode (dp)->dirents = malloc (nblks * sizeof (int));
       for (i = 0; i < nblks; i++)
-       dp->dn->dirents[i] = -1;
+       diskfs_node_disknode (dp)->dirents[i] = -1;
     }
 
   /* Scan through the entries to find ENTRY.  If we encounter
@@ -898,7 +901,7 @@ diskfs_get_directs (struct node *dp,
   bufvalid = 0;
   for (blkno = 0; blkno < nblks; blkno++)
     {
-      if (dp->dn->dirents[blkno] == -1)
+      if (diskfs_node_disknode (dp)->dirents[blkno] == -1)
        {
          err = count_dirents (dp, blkno, buf);
          if (err)
@@ -906,11 +909,11 @@ diskfs_get_directs (struct node *dp,
          bufvalid = 1;
        }
 
-      if (curentry + dp->dn->dirents[blkno] > entry)
+      if (curentry + diskfs_node_disknode (dp)->dirents[blkno] > entry)
        /* ENTRY starts in this block. */
        break;
 
-      curentry += dp->dn->dirents[blkno];
+      curentry += diskfs_node_disknode (dp)->dirents[blkno];
 
       bufvalid = 0;
     }
diff --git a/ext2fs/ext2fs.h b/ext2fs/ext2fs.h
index 3422af2..9667b6f 100644
--- a/ext2fs/ext2fs.h
+++ b/ext2fs/ext2fs.h
@@ -503,7 +503,7 @@ record_indir_poke (struct node *node, void *ptr)
   ext2_debug ("(%llu, %p)", node->cache_id, ptr);
   assert (disk_cache_block_is_ref (block));
   global_block_modified (block);
-  pokel_add (&node->dn->indir_pokel, block_ptr, block_size);
+  pokel_add (&diskfs_node_disknode (node)->indir_pokel, block_ptr, block_size);
 }
 
 /* ---------------------------------------------------------------- */
@@ -524,7 +524,7 @@ alloc_sync (struct node *np)
       if (np)
        {
          diskfs_node_update (np, 1);
-         pokel_sync (&np->dn->indir_pokel, 1);
+         pokel_sync (&diskfs_node_disknode (np)->indir_pokel, 1);
        }
       diskfs_set_hypermetadata (1, 0);
     }
diff --git a/ext2fs/getblk.c b/ext2fs/getblk.c
index d7ddb6a..0d0fab1 100644
--- a/ext2fs/getblk.c
+++ b/ext2fs/getblk.c
@@ -49,13 +49,13 @@ void
 ext2_discard_prealloc (struct node *node)
 {
 #ifdef EXT2_PREALLOCATE
-  if (node->dn->info.i_prealloc_count)
+  if (diskfs_node_disknode (node)->info.i_prealloc_count)
     {
-      int i = node->dn->info.i_prealloc_count;
+      int i = diskfs_node_disknode (node)->info.i_prealloc_count;
       ext2_debug ("discarding %d prealloced blocks for inode %d",
                  i, node->cache_id);
-      node->dn->info.i_prealloc_count = 0;
-      ext2_free_blocks (node->dn->info.i_prealloc_block, i);
+      diskfs_node_disknode (node)->info.i_prealloc_count = 0;
+      ext2_free_blocks (diskfs_node_disknode (node)->info.i_prealloc_block, i);
     }
 #endif
 }
@@ -72,12 +72,12 @@ ext2_alloc_block (struct node *node, block_t goal, int zero)
   block_t result;
 
 #ifdef EXT2_PREALLOCATE
-  if (node->dn->info.i_prealloc_count &&
-      (goal == node->dn->info.i_prealloc_block ||
-       goal + 1 == node->dn->info.i_prealloc_block))
+  if (diskfs_node_disknode (node)->info.i_prealloc_count &&
+      (goal == diskfs_node_disknode (node)->info.i_prealloc_block ||
+       goal + 1 == diskfs_node_disknode (node)->info.i_prealloc_block))
     {
-      result = node->dn->info.i_prealloc_block++;
-      node->dn->info.i_prealloc_count--;
+      result = diskfs_node_disknode (node)->info.i_prealloc_block++;
+      diskfs_node_disknode (node)->info.i_prealloc_count--;
       ext2_debug ("preallocation hit (%lu/%lu) => %u",
                  ++alloc_hits, ++alloc_attempts, result);
     }
@@ -95,8 +95,8 @@ ext2_alloc_block (struct node *node, block_t goal, int zero)
                                       EXT2_FEATURE_COMPAT_DIR_PREALLOC))
         ? sblock->s_prealloc_dir_blocks
         : 0,
-        &node->dn->info.i_prealloc_count,
-        &node->dn->info.i_prealloc_block);
+        &diskfs_node_disknode (node)->info.i_prealloc_count,
+        &diskfs_node_disknode (node)->info.i_prealloc_block);
     }
 #else
   result = ext2_new_block (goal, 0, 0);
@@ -124,15 +124,15 @@ inode_getblk (struct node *node, int nr, int create, int 
zero,
 
   assert (0 <= nr && nr < EXT2_N_BLOCKS);
 
-  *result = node->dn->info.i_data[nr];
+  *result = diskfs_node_disknode (node)->info.i_data[nr];
   if (*result)
     return 0;
 
   if (!create)
     return EINVAL;
 
-  if (node->dn->info.i_next_alloc_block == new_block)
-    goal = node->dn->info.i_next_alloc_goal;
+  if (diskfs_node_disknode (node)->info.i_next_alloc_block == new_block)
+    goal = diskfs_node_disknode (node)->info.i_next_alloc_goal;
 
 #ifdef EXT2FS_DEBUG
   hint = goal;
@@ -142,15 +142,16 @@ inode_getblk (struct node *node, int nr, int create, int 
zero,
     {
       for (i = nr - 1; i >= 0; i--)
        {
-         if (node->dn->info.i_data[i])
+         if (diskfs_node_disknode (node)->info.i_data[i])
            {
-             goal = node->dn->info.i_data[i];
+             goal = diskfs_node_disknode (node)->info.i_data[i];
              break;
            }
        }
       if (!goal)
        goal =
-         (node->dn->info.i_block_group * EXT2_BLOCKS_PER_GROUP (sblock))
+         (diskfs_node_disknode (node)->info.i_block_group
+           * EXT2_BLOCKS_PER_GROUP (sblock))
          + sblock->s_first_data_block;
     }
 
@@ -162,15 +163,15 @@ inode_getblk (struct node *node, int nr, int create, int 
zero,
   if (!*result)
     return ENOSPC;
 
-  node->dn->info.i_data[nr] = *result;
+  diskfs_node_disknode (node)->info.i_data[nr] = *result;
 
-  node->dn->info.i_next_alloc_block = new_block;
-  node->dn->info.i_next_alloc_goal = *result;
+  diskfs_node_disknode (node)->info.i_next_alloc_block = new_block;
+  diskfs_node_disknode (node)->info.i_next_alloc_goal = *result;
   node->dn_set_ctime = node->dn_set_mtime = 1;
   node->dn_stat.st_blocks += 1 << log2_stat_blocks_per_fs_block;
   node->dn_stat_dirty = 1;
 
-  if (diskfs_synchronous || node->dn->info.i_osync)
+  if (diskfs_synchronous || diskfs_node_disknode (node)->info.i_osync)
     diskfs_node_update (node, 1);
 
   return 0;
@@ -197,8 +198,8 @@ block_getblk (struct node *node, block_t block, int nr, int 
create, int zero,
       return EINVAL;
     }
 
-  if (node->dn->info.i_next_alloc_block == new_block)
-    goal = node->dn->info.i_next_alloc_goal;
+  if (diskfs_node_disknode (node)->info.i_next_alloc_block == new_block)
+    goal = diskfs_node_disknode (node)->info.i_next_alloc_goal;
   if (!goal)
     {
       for (i = nr - 1; i >= 0; i--)
@@ -222,13 +223,13 @@ block_getblk (struct node *node, block_t block, int nr, 
int create, int zero,
 
   bh[nr] = *result;
 
-  if (diskfs_synchronous || node->dn->info.i_osync)
+  if (diskfs_synchronous || diskfs_node_disknode (node)->info.i_osync)
     sync_global_ptr (bh, 1);
   else
     record_indir_poke (node, bh);
 
-  node->dn->info.i_next_alloc_block = new_block;
-  node->dn->info.i_next_alloc_goal = *result;
+  diskfs_node_disknode (node)->info.i_next_alloc_block = new_block;
+  diskfs_node_disknode (node)->info.i_next_alloc_goal = *result;
   node->dn_set_ctime = node->dn_set_mtime = 1;
   node->dn_stat.st_blocks += 1 << log2_stat_blocks_per_fs_block;
   node->dn_stat_dirty = 1;
@@ -260,13 +261,13 @@ ext2_getblk (struct node *node, block_t block, int 
create, block_t *disk_block)
    */
 
   ext2_debug ("block = %u, next = %u, goal = %u", block,
-             node->dn->info.i_next_alloc_block,
-             node->dn->info.i_next_alloc_goal);
+             diskfs_node_disknode (node)->info.i_next_alloc_block,
+             diskfs_node_disknode (node)->info.i_next_alloc_goal);
 
-  if (block == node->dn->info.i_next_alloc_block + 1)
+  if (block == diskfs_node_disknode (node)->info.i_next_alloc_block + 1)
     {
-      node->dn->info.i_next_alloc_block++;
-      node->dn->info.i_next_alloc_goal++;
+      diskfs_node_disknode (node)->info.i_next_alloc_block++;
+      diskfs_node_disknode (node)->info.i_next_alloc_goal++;
     }
 
   b = block;
diff --git a/ext2fs/ialloc.c b/ext2fs/ialloc.c
index 52212d5..7cfc4f3 100644
--- a/ext2fs/ialloc.c
+++ b/ext2fs/ialloc.c
@@ -316,14 +316,14 @@ diskfs_alloc_node (struct node *dir, mode_t mode, struct 
node **node)
     }
   /* Zero out the block pointers in case there's some noise left on disk.  */
   for (block = 0; block < EXT2_N_BLOCKS; block++)
-    if (np->dn->info.i_data[block] != 0)
+    if (diskfs_node_disknode (np)->info.i_data[block] != 0)
       {
-       np->dn->info.i_data[block] = 0;
+       diskfs_node_disknode (np)->info.i_data[block] = 0;
        np->dn_set_ctime = 1;
       }
-  if (np->dn->info_i_translator != 0)
+  if (diskfs_node_disknode (np)->info_i_translator != 0)
     {
-      np->dn->info_i_translator = 0;
+      diskfs_node_disknode (np)->info_i_translator = 0;
       np->dn_set_ctime = 1;
     }
   st->st_mode &= ~S_IPTRANS;
@@ -335,8 +335,9 @@ diskfs_alloc_node (struct node *dir, mode_t mode, struct 
node **node)
     }
 
   /* Propagate initial inode flags from the directory, as Linux does.  */
-  np->dn->info.i_flags =
-    ext2_mask_flags(mode, dir->dn->info.i_flags & EXT2_FL_INHERITED);
+  diskfs_node_disknode (np)->info.i_flags =
+    ext2_mask_flags(mode,
+              diskfs_node_disknode (dir)->info.i_flags & EXT2_FL_INHERITED);
 
   st->st_flags = 0;
 
diff --git a/ext2fs/inode.c b/ext2fs/inode.c
index 2a0c3cf..7af617c 100644
--- a/ext2fs/inode.c
+++ b/ext2fs/inode.c
@@ -78,7 +78,7 @@ static struct node *
 lookup (ino_t inum)
 {
   struct node *np;
-  for (np = nodehash[INOHASH(inum)]; np; np = np->dn->hnext)
+  for (np = nodehash[INOHASH(inum)]; np; np = diskfs_node_disknode (np)->hnext)
     if (np->cache_id == inum)
       return np;
   return NULL;
@@ -99,20 +99,18 @@ diskfs_cached_lookup (ino_t inum, struct node **npp)
     goto gotit;
   pthread_rwlock_unlock (&nodecache_lock);
 
+  /* Create the new node.  */
+  np = diskfs_make_node_alloc (sizeof *dn);
+  dn = diskfs_node_disknode (np);
+  np->cache_id = inum;
+
   /* Format specific data for the new node.  */
-  dn = malloc (sizeof (struct disknode));
-  if (! dn)
-    return ENOMEM;
   dn->dirents = 0;
   dn->dir_idx = 0;
   dn->pager = 0;
   pthread_rwlock_init (&dn->alloc_lock, NULL);
   pokel_init (&dn->indir_pokel, diskfs_disk_pager, disk_cache);
 
-  /* Create the new node.  */
-  np = diskfs_make_node (dn);
-  np->cache_id = inum;
-
   pthread_mutex_lock (&np->lock);
 
   /* Put NP in NODEHASH.  */
@@ -128,7 +126,7 @@ diskfs_cached_lookup (ino_t inum, struct node **npp)
 
   dn->hnext = nodehash[INOHASH(inum)];
   if (dn->hnext)
-    dn->hnext->dn->hprevp = &dn->hnext;
+    diskfs_node_disknode (dn->hnext)->hprevp = &dn->hnext;
   dn->hprevp = &nodehash[INOHASH(inum)];
   nodehash[INOHASH(inum)] = np;
   diskfs_nref_light (np);
@@ -184,15 +182,14 @@ ifind (ino_t inum)
 void
 diskfs_node_norefs (struct node *np)
 {
-  if (np->dn->dirents)
-    free (np->dn->dirents);
-  assert (!np->dn->pager);
+  if (diskfs_node_disknode (np)->dirents)
+    free (diskfs_node_disknode (np)->dirents);
+  assert (!diskfs_node_disknode (np)->pager);
 
   /* Move any pending writes of indirect blocks.  */
-  pokel_inherit (&global_pokel, &np->dn->indir_pokel);
-  pokel_finalize (&np->dn->indir_pokel);
+  pokel_inherit (&global_pokel, &diskfs_node_disknode (np)->indir_pokel);
+  pokel_finalize (&diskfs_node_disknode (np)->indir_pokel);
 
-  free (np->dn);
   free (np);
 }
 
@@ -202,7 +199,7 @@ void
 diskfs_try_dropping_softrefs (struct node *np)
 {
   pthread_rwlock_wrlock (&nodecache_lock);
-  if (np->dn->hprevp != NULL)
+  if (diskfs_node_disknode (np)->hprevp != NULL)
     {
       /* Check if someone reacquired a reference through the
         nodehash.  */
@@ -217,11 +214,12 @@ diskfs_try_dropping_softrefs (struct node *np)
          return;
        }
 
-      *np->dn->hprevp = np->dn->hnext;
-      if (np->dn->hnext)
-       np->dn->hnext->dn->hprevp = np->dn->hprevp;
-      np->dn->hnext = NULL;
-      np->dn->hprevp = NULL;
+      *diskfs_node_disknode (np)->hprevp = diskfs_node_disknode (np)->hnext;
+      if (diskfs_node_disknode (np)->hnext)
+       diskfs_node_disknode (diskfs_node_disknode (np)->hnext)->hprevp =
+          diskfs_node_disknode (np)->hprevp;
+      diskfs_node_disknode (np)->hnext = NULL;
+      diskfs_node_disknode (np)->hprevp = NULL;
       nodehash_nr_items -= 1;
       diskfs_nrele_light (np);
     }
@@ -250,7 +248,7 @@ read_node (struct node *np)
 {
   error_t err;
   struct stat *st = &np->dn_stat;
-  struct disknode *dn = np->dn;
+  struct disknode *dn = diskfs_node_disknode (np);
   struct ext2_inode *di;
   struct ext2_inode_info *info = &dn->info;
 
@@ -403,7 +401,7 @@ check_high_bits (struct node *np, long l)
      kernels".  Note that our check refuses to change the values, while
      Linux 2.3.42 just silently clears the high bits in an inode it updates,
      even if it was updating it for an unrelated reason.  */
-  if (np->dn->info.i_dtime != 0)
+  if (diskfs_node_disknode (np)->info.i_dtime != 0)
     return 0;
 
   return ((l & ~0xFFFF) == 0) ? 0 : EINVAL;
@@ -469,12 +467,12 @@ write_node (struct node *np)
 
   ext2_debug ("(%llu)", np->cache_id);
 
-  if (np->dn->info.i_prealloc_count)
+  if (diskfs_node_disknode (np)->info.i_prealloc_count)
     ext2_discard_prealloc (np);
 
   if (np->dn_stat_dirty)
     {
-      struct ext2_inode_info *info = &np->dn->info;
+      struct ext2_inode_info *info = &diskfs_node_disknode (np)->info;
 
       assert (!diskfs_readonly);
 
@@ -560,7 +558,7 @@ write_node (struct node *np)
       if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode))
        di->i_block[0] = st->st_rdev;
       else
-       memcpy (di->i_block, np->dn->info.i_data,
+       memcpy (di->i_block, diskfs_node_disknode (np)->info.i_data,
                EXT2_N_BLOCKS * sizeof di->i_block[0]);
 
       diskfs_end_catch_exception ();
@@ -578,7 +576,7 @@ write_node (struct node *np)
 error_t
 diskfs_node_reload (struct node *node)
 {
-  struct disknode *dn = node->dn;
+  struct disknode *dn = diskfs_node_disknode (node);
 
   if (dn->dirents)
     {
@@ -624,7 +622,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *))
 
   p = node_list;
   for (n = 0; n < INOHSZ; n++)
-    for (node = nodehash[n]; node; node = node->dn->hnext)
+    for (node = nodehash[n]; node; node = diskfs_node_disknode (node)->hnext)
       {
        *p++ = node;
 
@@ -663,7 +661,7 @@ write_all_disknodes ()
 
       /* Sync the indirect blocks here; they'll all be done before any
         inodes.  Waiting for them shouldn't be too bad.  */
-      pokel_sync (&node->dn->indir_pokel, 1);
+      pokel_sync (&diskfs_node_disknode (node)->indir_pokel, 1);
 
       diskfs_set_node_times (node);
 
@@ -745,7 +743,7 @@ diskfs_set_translator (struct node *np, const char *name, 
unsigned namelen,
     {
       /* Allocate block for translator */
       blkno =
-       ext2_new_block ((np->dn->info.i_block_group
+       ext2_new_block ((diskfs_node_disknode (np)->info.i_block_group
                         * EXT2_BLOCKS_PER_GROUP (sblock))
                        + sblock->s_first_data_block,
                        0, 0, 0);
@@ -757,7 +755,7 @@ diskfs_set_translator (struct node *np, const char *name, 
unsigned namelen,
        }
 
       di->i_translator = blkno;
-      np->dn->info_i_translator = blkno;
+      diskfs_node_disknode (np)->info_i_translator = blkno;
       record_global_poke (di);
 
       np->dn_stat.st_blocks += 1 << log2_stat_blocks_per_fs_block;
@@ -767,7 +765,7 @@ diskfs_set_translator (struct node *np, const char *name, 
unsigned namelen,
     {
       /* Clear block for translator going away. */
       di->i_translator = 0;
-      np->dn->info_i_translator = 0;
+      diskfs_node_disknode (np)->info_i_translator = 0;
       record_global_poke (di);
       ext2_free_blocks (blkno, 1);
 
@@ -856,7 +854,7 @@ write_symlink (struct node *node, const char *target)
 
   assert (node->dn_stat.st_blocks == 0);
 
-  memcpy (node->dn->info.i_data, target, len);
+  memcpy (diskfs_node_disknode (node)->info.i_data, target, len);
   node->dn_stat.st_size = len - 1;
   node->dn_set_ctime = 1;
   node->dn_set_mtime = 1;
@@ -873,7 +871,8 @@ read_symlink (struct node *node, char *target)
 
   assert (node->dn_stat.st_size < MAX_INODE_SYMLINK);
 
-  memcpy (target, node->dn->info.i_data, node->dn_stat.st_size);
+  memcpy (target, diskfs_node_disknode (node)->info.i_data,
+          node->dn_stat.st_size);
   return 0;
 }
 
diff --git a/ext2fs/pager.c b/ext2fs/pager.c
index a6c4fbb..b56c923 100644
--- a/ext2fs/pager.c
+++ b/ext2fs/pager.c
@@ -137,7 +137,7 @@ find_block (struct node *node, vm_offset_t offset,
 
   if (!*lock)
     {
-      *lock = &node->dn->alloc_lock;
+      *lock = &diskfs_node_disknode (node)->alloc_lock;
       pthread_rwlock_rdlock (*lock);
     }
 
@@ -279,7 +279,7 @@ file_pager_read_page (struct node *node, vm_offset_t page,
     err = do_pending_reads();
 
   if (!err && partial && !*writelock)
-    node->dn->last_page_partially_writable = 1;
+    diskfs_node_disknode (node)->last_page_partially_writable = 1;
 
   if (lock)
     pthread_rwlock_unlock (lock);
@@ -377,16 +377,16 @@ file_pager_write_page (struct node *node, vm_offset_t 
offset, void *buf)
 {
   error_t err = 0;
   struct pending_blocks pb;
-  pthread_rwlock_t *lock = &node->dn->alloc_lock;
+  pthread_rwlock_t *lock = &diskfs_node_disknode (node)->alloc_lock;
   block_t block;
   int left = vm_page_size;
 
   pending_blocks_init (&pb, buf);
 
-  /* Holding NODE->dn->alloc_lock effectively locks NODE->allocsize,
+  /* Holding diskfs_node_disknode (node)->alloc_lock effectively locks 
NODE->allocsize,
      at least for the cases we care about: pager_unlock_page,
      diskfs_grow and diskfs_truncate.  */
-  pthread_rwlock_rdlock (&node->dn->alloc_lock);
+  pthread_rwlock_rdlock (&diskfs_node_disknode (node)->alloc_lock);
 
   if (offset >= node->allocsize)
     left = 0;
@@ -411,7 +411,7 @@ file_pager_write_page (struct node *node, vm_offset_t 
offset, void *buf)
   if (!err)
     pending_blocks_write (&pb);
 
-  pthread_rwlock_unlock (&node->dn->alloc_lock);
+  pthread_rwlock_unlock (&diskfs_node_disknode (node)->alloc_lock);
 
   return err;
 }
@@ -583,7 +583,7 @@ pager_unlock_page (struct user_pager_info *pager, 
vm_offset_t page)
       error_t err;
       volatile int partial_page;
       struct node *node = pager->node;
-      struct disknode *dn = node->dn;
+      struct disknode *dn = diskfs_node_disknode (node);
 
       pthread_rwlock_wrlock (&dn->alloc_lock);
 
@@ -656,7 +656,7 @@ diskfs_grow (struct node *node, off_t size, struct protid 
*cred)
       volatile off_t new_size;
       volatile block_t end_block;
       block_t new_end_block;
-      struct disknode *dn = node->dn;
+      struct disknode *dn = diskfs_node_disknode (node);
 
       pthread_rwlock_wrlock (&dn->alloc_lock);
 
@@ -741,7 +741,7 @@ diskfs_file_update (struct node *node, int wait)
   struct pager *pager;
 
   pthread_spin_lock (&node_to_page_lock);
-  pager = node->dn->pager;
+  pager = diskfs_node_disknode (node)->pager;
   if (pager)
     ports_port_ref (pager);
   pthread_spin_unlock (&node_to_page_lock);
@@ -752,7 +752,7 @@ diskfs_file_update (struct node *node, int wait)
       ports_port_deref (pager);
     }
 
-  pokel_sync (&node->dn->indir_pokel, wait);
+  pokel_sync (&diskfs_node_disknode (node)->indir_pokel, wait);
 
   diskfs_node_update (node, wait);
 }
@@ -762,7 +762,7 @@ void
 flush_node_pager (struct node *node)
 {
   struct pager *pager;
-  struct disknode *dn = node->dn;
+  struct disknode *dn = diskfs_node_disknode (node);
 
   pthread_spin_lock (&node_to_page_lock);
   pager = dn->pager;
@@ -806,9 +806,9 @@ pager_clear_user_data (struct user_pager_info *upi)
       struct pager *pager;
 
       pthread_spin_lock (&node_to_page_lock);
-      pager = upi->node->dn->pager;
+      pager = diskfs_node_disknode (upi->node)->pager;
       if (pager && pager_get_upi (pager) == upi)
-       upi->node->dn->pager = 0;
+       diskfs_node_disknode (upi->node)->pager = 0;
       pthread_spin_unlock (&node_to_page_lock);
 
       diskfs_nrele_light (upi->node);
@@ -1236,7 +1236,7 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot)
   pthread_spin_lock (&node_to_page_lock);
   do
     {
-      struct pager *pager = node->dn->pager;
+      struct pager *pager = diskfs_node_disknode (node)->pager;
       if (pager)
        {
          /* Because PAGER is not a real reference,
@@ -1245,9 +1245,9 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot)
             and loop.  The deallocation will complete separately. */
          right = pager_get_port (pager);
          if (right == MACH_PORT_NULL)
-           node->dn->pager = 0;
-         else
-           pager_get_upi (pager)->max_prot |= prot;
+           diskfs_node_disknode (node)->pager = 0;
+         else
+           pager_get_upi (pager)->max_prot |= prot;
        }
       else
        {
@@ -1257,10 +1257,10 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot)
          upi->node = node;
          upi->max_prot = prot;
          diskfs_nref_light (node);
-         node->dn->pager =
-           pager_create (upi, file_pager_bucket, MAY_CACHE,
-                         MEMORY_OBJECT_COPY_DELAY, 0);
-         if (node->dn->pager == 0)
+         diskfs_node_disknode (node)->pager =
+                   pager_create (upi, file_pager_bucket, MAY_CACHE,
+                                 MEMORY_OBJECT_COPY_DELAY, 0);
+         if (diskfs_node_disknode (node)->pager == 0)
            {
              diskfs_nrele_light (node);
              free (upi);
@@ -1268,8 +1268,8 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot)
              return MACH_PORT_NULL;
            }
 
-         right = pager_get_port (node->dn->pager);
-         ports_port_deref (node->dn->pager);
+         right = pager_get_port (diskfs_node_disknode (node)->pager);
+         ports_port_deref (diskfs_node_disknode (node)->pager);
        }
     }
   while (right == MACH_PORT_NULL);
@@ -1289,7 +1289,7 @@ drop_pager_softrefs (struct node *node)
   struct pager *pager;
 
   pthread_spin_lock (&node_to_page_lock);
-  pager = node->dn->pager;
+  pager = diskfs_node_disknode (node)->pager;
   if (pager)
     ports_port_ref (pager);
   pthread_spin_unlock (&node_to_page_lock);
@@ -1311,7 +1311,7 @@ allow_pager_softrefs (struct node *node)
   struct pager *pager;
 
   pthread_spin_lock (&node_to_page_lock);
-  pager = node->dn->pager;
+  pager = diskfs_node_disknode (node)->pager;
   if (pager)
     ports_port_ref (pager);
   pthread_spin_unlock (&node_to_page_lock);
@@ -1331,7 +1331,7 @@ diskfs_get_filemap_pager_struct (struct node *node)
 {
   /* This is safe because pager can't be cleared; there must be
      an active mapping for this to be called. */
-  return node->dn->pager;
+  return diskfs_node_disknode (node)->pager;
 }
 
 /* Shutdown all the pagers (except the disk pager). */
diff --git a/ext2fs/truncate.c b/ext2fs/truncate.c
index 63d2295..15e5541 100644
--- a/ext2fs/truncate.c
+++ b/ext2fs/truncate.c
@@ -100,7 +100,7 @@ free_block_run_finish (struct free_block_run *fbr)
 static void
 trunc_direct (struct node *node, block_t end, struct free_block_run *fbr)
 {
-  block_t *blocks = node->dn->info.i_data;
+  block_t *blocks = diskfs_node_disknode (node)->info.i_data;
 
   ext2_debug ("truncating direct blocks from %d", end);
 
@@ -230,7 +230,7 @@ force_delayed_copies (struct node *node, off_t length)
   struct pager *pager;
 
   pthread_spin_lock (&node_to_page_lock);
-  pager = node->dn->pager;
+  pager = diskfs_node_disknode (node)->pager;
   if (pager)
     ports_port_ref (pager);
   pthread_spin_unlock (&node_to_page_lock);
@@ -260,7 +260,7 @@ enable_delayed_copies (struct node *node)
   struct pager *pager;
 
   pthread_spin_lock (&node_to_page_lock);
-  pager = node->dn->pager;
+  pager = diskfs_node_disknode (node)->pager;
   if (pager)
     ports_port_ref (pager);
   pthread_spin_unlock (&node_to_page_lock);
@@ -322,7 +322,7 @@ diskfs_truncate (struct node *node, off_t length)
 
   force_delayed_copies (node, length);
 
-  pthread_rwlock_wrlock (&node->dn->alloc_lock);
+  pthread_rwlock_wrlock (&diskfs_node_disknode (node)->alloc_lock);
 
   /* Update the size on disk; fsck will finish freeing blocks if necessary
      should we crash. */
@@ -335,7 +335,7 @@ diskfs_truncate (struct node *node, off_t length)
   if (!err)
     {
       block_t end = boffs_block (round_block (length)), offs;
-      block_t *bptrs = node->dn->info.i_data;
+      block_t *bptrs = diskfs_node_disknode (node)->info.i_data;
       struct free_block_run fbr;
 
       free_block_run_init (&fbr, node);
@@ -355,8 +355,8 @@ diskfs_truncate (struct node *node, off_t length)
 
       /* Set our last_page_partially_writable to a pessimistic state -- it
         won't hurt if is wrong.  */
-      node->dn->last_page_partially_writable =
-       trunc_page (node->allocsize) != node->allocsize;
+      diskfs_node_disknode (node)->last_page_partially_writable =
+               trunc_page (node->allocsize) != node->allocsize;
 
       diskfs_end_catch_exception ();
     }
@@ -368,7 +368,7 @@ diskfs_truncate (struct node *node, off_t length)
   /* Now we can permit delayed copies again. */
   enable_delayed_copies (node);
 
-  pthread_rwlock_unlock (&node->dn->alloc_lock);
+  pthread_rwlock_unlock (&diskfs_node_disknode (node)->alloc_lock);
 
   return err;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]