i noticed a spurious grab/release of i_sem in hpfs' unlink method.
then i noticed some other... infelicities.  if i keep going at this,
I'll be here all night, and I have more pressing things to fix (ie
file locking).  this patch:

 * removes unnecessary i_sem locking in hpfs_unlink
 * changes the return value of hpfs_remove_dirent to be an errno
   instead of an encoding of that errno.
 * changes all callers.
 * minor code reformatting and cleanups.

diff -urNX dontdiff linux-t9p7/fs/hpfs/dnode.c linux-willy/fs/hpfs/dnode.c
--- linux-t9p7/fs/hpfs/dnode.c  Tue Sep  5 22:07:29 2000
+++ linux-willy/fs/hpfs/dnode.c Mon Oct  2 05:36:50 2000
@@ -689,7 +689,7 @@
        if (de->first || de->last) {
                hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or 
last dirent in dnode %08x", dno);
                hpfs_brelse4(qbh);
-               return 1;
+               return -EFSERROR;
        }
        if (de->down) down = de_down_pointer(de);
        if (depth && (de->down || (de == dnode_first_de(dnode) && 
de_next_de(de)->last))) {
@@ -698,7 +698,7 @@
                if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) {
                        hpfs_brelse4(qbh);
                        hpfs_unlock_creation(i->i_sb);
-                       return 2;
+                       return -ENOSPC;
                }
        }
        i->i_version = ++event;
@@ -711,7 +711,7 @@
                for_all_poss(i, hpfs_pos_subst, 5, t);
                if (a) delete_empty_dnode(i, a);
                if (lock) hpfs_unlock_creation(i->i_sb);
-               return !a;
+               return a ? 0 : -EFSERROR;
        }
        delete_empty_dnode(i, dno);
        if (lock) hpfs_unlock_creation(i->i_sb);
diff -urNX dontdiff linux-t9p7/fs/hpfs/namei.c linux-willy/fs/hpfs/namei.c
--- linux-t9p7/fs/hpfs/namei.c  Tue Sep  5 22:07:29 2000
+++ linux-willy/fs/hpfs/namei.c Mon Oct  2 05:04:02 2000
@@ -302,10 +302,10 @@
        struct inode *inode = dentry->d_inode;
        dnode_secno dno;
        fnode_secno fno;
-       int r;
+       int result;
        int rep = 0;
        hpfs_adjust_length((char *)name, &len);
-       again:
+again:
        hpfs_lock_2inodes(dir, inode);
        if (!(de = map_dirent(dir, dir->i_hpfs_dno, (char *)name, len, &dno, &qbh))) {
                hpfs_unlock_2inodes(dir, inode);
@@ -322,8 +322,10 @@
                return -EISDIR;
        }
        fno = de->fnode;
-       if ((r = hpfs_remove_dirent(dir, dno, de, &qbh, 1)) == 1) 
hpfs_error(dir->i_sb, "there was error when removing dirent");
-       if (r != 2) {
+       result = hpfs_remove_dirent(dir, dno, de, &qbh, 1);
+       if (result == -EFSERROR)
+               hpfs_error(dir->i_sb, "there was error when removing dirent");
+       if (result != -ENOSPC) {
                inode->i_nlink--;
                hpfs_unlock_2inodes(dir, inode);
        } else {        /* no space for deleting, try to truncate file */
@@ -340,19 +342,17 @@
                        goto ret;
                }
                /*printk("HPFS: truncating file before delete.\n");*/
-               down(&inode->i_sem);
                newattrs.ia_size = 0;
                newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
                err = notify_change(dentry, &newattrs);
-               up(&inode->i_sem);
                put_write_access(inode);
                if (err)
                        goto ret;
                rep = 1;
                goto again;
        }
-       ret:
-       return r == 2 ? -ENOSPC : r == 1 ? -EFSERROR : 0;
+ret:
+       return result;
 }
 
 int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
@@ -365,7 +365,7 @@
        dnode_secno dno;
        fnode_secno fno;
        int n_items = 0;
-       int r;
+       int result;
        hpfs_adjust_length((char *)name, &len);
        hpfs_lock_2inodes(dir, inode);
        if (!(de = map_dirent(dir, dir->i_hpfs_dno, (char *)name, len, &dno, &qbh))) {
@@ -389,14 +389,16 @@
                return -ENOTEMPTY;
        }
        fno = de->fnode;
-       if ((r = hpfs_remove_dirent(dir, dno, de, &qbh, 1)) == 1)
+       if ((result = hpfs_remove_dirent(dir, dno, de, &qbh, 1)) == -EFSERROR)
                hpfs_error(dir->i_sb, "there was error when removing dirent");
-       if (r != 2) {
+       if (result != -ENOSPC) {
                dir->i_nlink--;
                inode->i_nlink = 0;
                hpfs_unlock_2inodes(dir, inode);
-       } else hpfs_unlock_2inodes(dir, inode);
-       return r == 2 ? -ENOSPC : r == 1 ? -EFSERROR : 0;
+       } else {
+               hpfs_unlock_2inodes(dir, inode);
+       }
+       return result;
 }
 
 int hpfs_symlink_readpage(struct file *file, struct page *page)
@@ -467,8 +469,8 @@
        de.hidden = new_name[0] == '.';
 
        if (new_inode) {
-               int r;
-               if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 1)) != 2) {
+               err = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 1);
+               if (err != -ENOSPC) {
                        if ((nde = map_dirent(new_dir, new_dir->i_hpfs_dno, (char 
*)new_name, new_len, NULL, &qbh1))) {
                                new_inode->i_nlink = 0;
                                copy_de(nde, &de);
@@ -481,7 +483,6 @@
                        err = -EFSERROR;
                        goto end1;
                }
-               err = r == 2 ? -ENOSPC : r == 1 ? -EFSERROR : 0;
                goto end1;
        }
 
@@ -504,15 +505,14 @@
                        goto end1;
                }
 
-       if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) {
+       if ((err = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) {
                hpfs_unlock_creation(i->i_sb);
                hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent");
-               err = r == 2 ? -ENOSPC : -EFSERROR;
                goto end1;
        }
        hpfs_unlock_creation(i->i_sb);
        
-       end:
+end:
        i->i_hpfs_parent_dir = new_dir->i_ino;
        if (S_ISDIR(i->i_mode)) {
                new_dir->i_nlink++;
@@ -528,7 +528,7 @@
        }
        i->i_hpfs_conv = i->i_sb->s_hpfs_conv;
        hpfs_decide_conv(i, (char *)new_name, new_len);
-       end1:
+end1:
        hpfs_unlock_3inodes(old_dir, new_dir, i);
        return err;
 }

-- 
Revolutions do not require corporate support.
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]

Reply via email to