Messages in this thread Patch in this message | | | Date | Fri, 12 Nov 1999 20:53:38 +0100 (CET) | From | Urban Widmark <> | Subject | Re: smbfs: "rm -rf" dircache problems [w/ patch] |
| |
On Fri, 12 Nov 1999, Urban Widmark wrote:
> sources). I'll clean it up and post a patch for comments (and testing for > those brave enough :).
As promised. Maybe this is totally wrong but it makes my rm -rf problems go away. I'd like some comments and/or testers before submitting it to the maintainer.
Patch for 2.2.13 (it could also work with 2.3.x, they are not that different).
/Urban diff -ur linux-2.2.13-orig/fs/smbfs/cache.c linux/fs/smbfs/cache.c --- linux-2.2.13-orig/fs/smbfs/cache.c Mon Mar 8 00:25:23 1999 +++ linux/fs/smbfs/cache.c Fri Nov 12 20:08:35 1999 @@ -290,6 +290,7 @@ if (!result) { cachep->valid = 1; + cachep->mtime = dentry->d_inode->i_mtime; } #ifdef SMBFS_DEBUG_VERBOSE printk("smb_refill_cache: cache %s/%s status=%d, entries=%d\n", diff -ur linux-2.2.13-orig/fs/smbfs/dir.c linux/fs/smbfs/dir.c --- linux-2.2.13-orig/fs/smbfs/dir.c Fri Nov 12 01:53:58 1999 +++ linux/fs/smbfs/dir.c Fri Nov 12 20:29:38 1999 @@ -87,6 +87,21 @@ printk("smb_readdir: reading %s/%s, f_pos=%d\n", dentry->d_parent->d_name.name, dentry->d_name.name, (int) filp->f_pos); #endif + + result = 0; + switch ((unsigned int) filp->f_pos) + { + case 0: + if (filldir(dirent, ".", 1, 0, dir->i_ino) < 0) + goto out_free; + filp->f_pos = 1; + case 1: + if (filldir(dirent, "..", 2, 1, + dentry->d_parent->d_inode->i_ino) < 0) + goto out_free; + filp->f_pos = 2; + } + /* * Make sure our inode is up-to-date. */ @@ -103,7 +118,9 @@ /* * Make sure the cache is up-to-date. */ - if (!cachep->valid) + if (!cachep->valid || + (cachep->mtime != dentry->d_inode->i_mtime && + filp->f_pos == 2) ) { result = smb_refill_dircache(cachep, dentry); if (result) @@ -111,19 +128,6 @@ } result = 0; - switch ((unsigned int) filp->f_pos) - { - case 0: - if (filldir(dirent, ".", 1, 0, dir->i_ino) < 0) - goto out_free; - filp->f_pos = 1; - case 1: - if (filldir(dirent, "..", 2, 1, - dentry->d_parent->d_inode->i_ino) < 0) - goto out_free; - filp->f_pos = 2; - } - while (1) { struct cache_dirent this_dirent, *entry = &this_dirent; @@ -424,7 +428,6 @@ dentry->d_parent->d_name.name, dentry->d_name.name, mode); #endif - smb_invalid_dir_cache(dir); error = smb_proc_create(dentry, 0, CURRENT_TIME, &fileid); if (!error) { @@ -445,7 +448,6 @@ { int error; - smb_invalid_dir_cache(dir); error = smb_proc_mkdir(dentry); if (!error) { @@ -472,7 +474,6 @@ if (!list_empty(&dentry->d_hash)) goto out; - smb_invalid_dir_cache(dir); error = smb_proc_rmdir(dentry); out: @@ -489,7 +490,6 @@ */ smb_close(dentry->d_inode); - smb_invalid_dir_cache(dir); error = smb_proc_unlink(dentry); if (!error) { @@ -527,8 +527,6 @@ d_delete(new_dentry); } - smb_invalid_dir_cache(old_dir); - smb_invalid_dir_cache(new_dir); error = smb_proc_mv(old_dentry, new_dentry); if (!error) { diff -ur linux-2.2.13-orig/fs/smbfs/inode.c linux/fs/smbfs/inode.c --- linux-2.2.13-orig/fs/smbfs/inode.c Fri Nov 12 01:54:22 1999 +++ linux/fs/smbfs/inode.c Fri Nov 12 20:29:12 1999 @@ -276,8 +276,6 @@ #endif if (!S_ISDIR(inode->i_mode)) invalidate_inode_pages(inode); - else - smb_invalid_dir_cache(inode); } out: return error; diff -ur linux-2.2.13-orig/include/linux/smb_fs.h linux/include/linux/smb_fs.h --- linux-2.2.13-orig/include/linux/smb_fs.h Fri Nov 12 01:54:24 1999 +++ linux/include/linux/smb_fs.h Thu Nov 11 23:09:45 1999 @@ -182,6 +182,8 @@ struct cache_block * block; }; +/* where did 64 come from? Just a nice alignment value? if so we still have + space ... I hope :) */ #define NINDEX (PAGE_SIZE-64)/sizeof(struct cache_index) /* * The cache head is mapped as the page at offset 0. @@ -192,6 +194,7 @@ int entries; /* total entries */ int pages; /* number of data pages */ int idx; /* index of current data page */ + time_t mtime; /* the last mtime of our dir inode */ struct cache_index index[NINDEX]; }; | |