[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
hurd/fatfs ChangeLog fatfs.h inode.c
From: |
Marcus Brinkmann |
Subject: |
hurd/fatfs ChangeLog fatfs.h inode.c |
Date: |
Wed, 06 Aug 2003 17:47:57 -0400 |
CVSROOT: /cvsroot/hurd
Module name: hurd
Branch:
Changes by: Marcus Brinkmann <address@hidden> 03/08/06 17:47:57
Modified files:
fatfs : ChangeLog fatfs.h inode.c
Log message:
2003-08-03 Marco Gerards <address@hidden>
* fatfs.h (struct disknode): New member DIRNODE.
* inode.c (read_node): Added assertion to be sure the directory
can always be found. Add directory dependancy to node by
initializing DIRNODE and holding a reference.
(diskfs_node_norefs): Release reference to DIRNODE.
(write_node): Don't use diskfs_cached_lookup to lookup the
directory, use DIRNODE instead and lock DP. Don't use diskfs_nput,
use mutex_unlock instead.
(diskfs_alloc_node): Add directory dependancy to node by
initializing DIRNODE and holding a reference.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/fatfs/ChangeLog.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/fatfs/fatfs.h.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/fatfs/inode.c.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
Patches:
Index: hurd/fatfs/ChangeLog
diff -u hurd/fatfs/ChangeLog:1.8 hurd/fatfs/ChangeLog:1.9
--- hurd/fatfs/ChangeLog:1.8 Mon Aug 4 18:26:14 2003
+++ hurd/fatfs/ChangeLog Wed Aug 6 17:47:57 2003
@@ -1,3 +1,16 @@
+2003-08-03 Marco Gerards <address@hidden>
+
+ * fatfs.h (struct disknode): New member DIRNODE.
+ * inode.c (read_node): Added assertion to be sure the directory
+ can always be found. Add directory dependancy to node by
+ initializing DIRNODE and holding a reference.
+ (diskfs_node_norefs): Release reference to DIRNODE.
+ (write_node): Don't use diskfs_cached_lookup to lookup the
+ directory, use DIRNODE instead and lock DP. Don't use diskfs_nput,
+ use mutex_unlock instead.
+ (diskfs_alloc_node): Add directory dependancy to node by
+ initializing DIRNODE and holding a reference.
+
2003-08-05 Marcus Brinkmann <address@hidden>
* fat.c (fat_read_sblock): Catch error from store_read.
Index: hurd/fatfs/fatfs.h
diff -u hurd/fatfs/fatfs.h:1.4 hurd/fatfs/fatfs.h:1.5
--- hurd/fatfs/fatfs.h:1.4 Tue Jul 29 10:58:44 2003
+++ hurd/fatfs/fatfs.h Wed Aug 6 17:47:57 2003
@@ -42,6 +42,9 @@
/* The inode as returned by virtual inode management routines. */
inode_t inode;
+ /* The directory that hold this file, always hold a reference. */
+ struct node *dirnode;
+
struct rwlock dirent_lock;
char *link_target; /* For S_ISLNK. */
Index: hurd/fatfs/inode.c
diff -u hurd/fatfs/inode.c:1.4 hurd/fatfs/inode.c:1.5
--- hurd/fatfs/inode.c:1.4 Sun Aug 3 16:53:54 2003
+++ hurd/fatfs/inode.c Wed Aug 6 17:47:57 2003
@@ -223,6 +223,15 @@
if (np->dn->translator)
free (np->dn->translator);
+ /* It is safe to unlock diskfs_node_refcnt_lock here for a while because
+ all references to the node have been deleted. */
+ if (np->dn->dirnode)
+ {
+ spin_unlock (&diskfs_node_refcnt_lock);
+ diskfs_nrele (np->dn->dirnode);
+ spin_lock (&diskfs_node_refcnt_lock);
+ }
+
assert (!np->dn->pager);
free (np->dn);
@@ -255,7 +264,7 @@
static error_t
read_node (struct node *np, vm_address_t buf)
{
- /* XXX This needs careful investigation */
+ /* XXX This needs careful investigation. */
error_t err;
struct stat *st = &np->dn_stat;
struct disknode *dn = np->dn;
@@ -267,6 +276,30 @@
vm_size_t buflen = 0;
int our_buf = 0;
+ st->st_fstype = FSTYPE_MSLOSS;
+ st->st_fsid = getpid ();
+ st->st_ino = np->cache_id;
+ st->st_gen = 0;
+ st->st_rdev = 0;
+
+ st->st_nlink = 1;
+ st->st_uid = fs_uid;
+ st->st_gid = fs_gid;
+
+ st->st_rdev = 0;
+
+ np->dn->translator = 0;
+ np->dn->translen = 0;
+
+ st->st_flags = 0;
+
+ /* FIXME: If we are called through diskfs_alloc_node for a newly
+ allocated node that has no directory entry yet, only set a
+ minimal amount of data until the dirent is created (and we get
+ called a second time?). */
+ if (vk.dir_inode == 0 && vk.dir_offset == (void *) 2)
+ return 0;
+
if (vk.dir_inode == 0)
dr = &dr_root_node;
else
@@ -277,6 +310,7 @@
by libdiskfs. The only case it is not locked is for NFS
(fsys_getfile) and we disabled that. */
dp = ifind (vk.dir_inode);
+ assert (dp);
/* Map in the directory contents. */
memobj = diskfs_get_filemap (dp, prot);
@@ -294,30 +328,10 @@
dr = (struct dirrect *) (buf + vk.dir_offset);
}
- st->st_fstype = FSTYPE_MSLOSS;
- st->st_fsid = getpid ();
- st->st_ino = np->cache_id;
- st->st_gen = 0;
- st->st_rdev = 0;
-
- st->st_nlink = 1;
- st->st_uid = fs_uid;
- st->st_gid = fs_gid;
-
- st->st_rdev = 0;
-
- np->dn->translator = 0;
- np->dn->translen = 0;
-
- st->st_flags = 0;
-
- /* If we are called for a newly allocated node that has no directory
- entry yet, only set a minimal amount of data until the dirent is
- created (and we get called a second time?). */
- /* We will avoid this by overriding the relevant functions.
- if (dr == (void *)1)
- return 0;
- */
+ /* Files in fatfs depend on the directory that hold the file. */
+ np->dn->dirnode = dp;
+ if (dp)
+ dp->references++;
rwlock_reader_lock(&np->dn->dirent_lock);
@@ -464,15 +478,20 @@
{
assert (!diskfs_readonly);
- err = diskfs_cached_lookup (vk.dir_inode, &dp);
- if (err)
- return;
+ dp = np->dn->dirnode;
+ assert (dp);
+
+ mutex_lock (&dp->lock);
/* Map in the directory contents. */
memobj = diskfs_get_filemap (dp, prot);
if (memobj == MACH_PORT_NULL)
- return;
+ {
+ mutex_unlock (&dp->lock);
+ /* FIXME: We shouldn't ignore this error. */
+ return;
+ }
buflen = round_page (dp->dn_stat.st_size);
err = vm_map (mach_task_self (),
@@ -487,7 +506,7 @@
write_dword (dr->file_size, st->st_size);
- /* Write time. */
+ /* Write time. */
fat_from_epoch ((unsigned char *) &dr->write_date,
(unsigned char *) &dr->write_time, &st->st_mtime);
@@ -495,7 +514,7 @@
np->dn_stat_dirty = 0;
munmap ((caddr_t) buf, buflen);
- diskfs_nput (dp);
+ mutex_unlock (&dp->lock);
}
}
@@ -745,13 +764,19 @@
assert (!diskfs_readonly);
- err = vi_new((struct vi_key) {0,1} /* XXX not allocated yet */, &inum,
&inode);
+ /* FIXME: We use a magic key here that signals read_node that we are
+ not entered in any directory yet. */
+ err = vi_new((struct vi_key) {0,2}, &inum, &inode);
if (err)
return err;
err = diskfs_cached_lookup (inum, &np);
if (err)
return err;
+
+ /* FIXME: We know that readnode couldn't put this in. */
+ np->dn->dirnode = dir;
+ dir->references++;
*node = np;
return 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- hurd/fatfs ChangeLog fatfs.h inode.c,
Marcus Brinkmann <=