Commit 4c5378a9 authored by Dave Kleikamp's avatar Dave Kleikamp Committed by Linus Torvalds

[PATCH] jfs_readdir does not need to grab BKL

parent 425fff9f
...@@ -2868,8 +2868,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -2868,8 +2868,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (filp->f_pos == DIREND) if (filp->f_pos == DIREND)
return 0; return 0;
lock_kernel();
if (DO_INDEX(ip)) { if (DO_INDEX(ip)) {
/* /*
* persistent index is stored in directory entries. * persistent index is stored in directory entries.
...@@ -2887,14 +2885,12 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -2887,14 +2885,12 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (dtEmpty(ip)) { if (dtEmpty(ip)) {
filp->f_pos = DIREND; filp->f_pos = DIREND;
unlock_kernel();
return 0; return 0;
} }
repeat: repeat:
rc = get_index(ip, dir_index, &dirtab_slot); rc = get_index(ip, dir_index, &dirtab_slot);
if (rc) { if (rc) {
filp->f_pos = DIREND; filp->f_pos = DIREND;
unlock_kernel();
return rc; return rc;
} }
if (dirtab_slot.flag == DIR_INDEX_FREE) { if (dirtab_slot.flag == DIR_INDEX_FREE) {
...@@ -2902,13 +2898,11 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -2902,13 +2898,11 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
jERROR(1, ("jfs_readdir detected " jERROR(1, ("jfs_readdir detected "
"infinite loop!\n")); "infinite loop!\n"));
filp->f_pos = DIREND; filp->f_pos = DIREND;
unlock_kernel();
return 0; return 0;
} }
dir_index = le32_to_cpu(dirtab_slot.addr2); dir_index = le32_to_cpu(dirtab_slot.addr2);
if (dir_index == -1) { if (dir_index == -1) {
filp->f_pos = DIREND; filp->f_pos = DIREND;
unlock_kernel();
return 0; return 0;
} }
goto repeat; goto repeat;
...@@ -2918,14 +2912,12 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -2918,14 +2912,12 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
DT_GETPAGE(ip, bn, mp, PSIZE, p, rc); DT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc) { if (rc) {
filp->f_pos = DIREND; filp->f_pos = DIREND;
unlock_kernel();
return 0; return 0;
} }
if (p->header.flag & BT_INTERNAL) { if (p->header.flag & BT_INTERNAL) {
jERROR(1,("jfs_readdir: bad index table\n")); jERROR(1,("jfs_readdir: bad index table\n"));
DT_PUTPAGE(mp); DT_PUTPAGE(mp);
filp->f_pos = -1; filp->f_pos = -1;
unlock_kernel();
return 0; return 0;
} }
} else { } else {
...@@ -2935,34 +2927,26 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -2935,34 +2927,26 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
*/ */
filp->f_pos = 0; filp->f_pos = 0;
if (filldir(dirent, ".", 1, 0, ip->i_ino, if (filldir(dirent, ".", 1, 0, ip->i_ino,
DT_DIR)) { DT_DIR))
unlock_kernel();
return 0; return 0;
}
} }
/* /*
* parent ".." * parent ".."
*/ */
filp->f_pos = 1; filp->f_pos = 1;
if (filldir if (filldir(dirent, "..", 2, 1, PARENT(ip), DT_DIR))
(dirent, "..", 2, 1, PARENT(ip), DT_DIR)) {
unlock_kernel();
return 0; return 0;
}
/* /*
* Find first entry of left-most leaf * Find first entry of left-most leaf
*/ */
if (dtEmpty(ip)) { if (dtEmpty(ip)) {
filp->f_pos = DIREND; filp->f_pos = DIREND;
unlock_kernel();
return 0; return 0;
} }
if ((rc = dtReadFirst(ip, &btstack))) { if ((rc = dtReadFirst(ip, &btstack)))
unlock_kernel();
return -rc; return -rc;
}
DT_GETSEARCH(ip, btstack.top, bn, mp, p, index); DT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
} }
...@@ -2981,10 +2965,8 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -2981,10 +2965,8 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/* build "." entry */ /* build "." entry */
if (filldir(dirent, ".", 1, filp->f_pos, ip->i_ino, if (filldir(dirent, ".", 1, filp->f_pos, ip->i_ino,
DT_DIR)) { DT_DIR))
unlock_kernel();
return 0; return 0;
}
dtoffset->index = 1; dtoffset->index = 1;
} }
...@@ -2993,10 +2975,8 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -2993,10 +2975,8 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/* build ".." entry */ /* build ".." entry */
if (filldir(dirent, "..", 2, filp->f_pos, if (filldir(dirent, "..", 2, filp->f_pos,
PARENT(ip), DT_DIR)) { PARENT(ip), DT_DIR))
unlock_kernel();
return 0; return 0;
}
} else { } else {
jERROR(1, jERROR(1,
("jfs_readdir called with invalid offset!\n")); ("jfs_readdir called with invalid offset!\n"));
...@@ -3007,7 +2987,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -3007,7 +2987,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (dtEmpty(ip)) { if (dtEmpty(ip)) {
filp->f_pos = DIREND; filp->f_pos = DIREND;
unlock_kernel();
return 0; return 0;
} }
...@@ -3016,7 +2995,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -3016,7 +2995,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
("jfs_readdir: unexpected rc = %d from dtReadNext\n", ("jfs_readdir: unexpected rc = %d from dtReadNext\n",
rc)); rc));
filp->f_pos = DIREND; filp->f_pos = DIREND;
unlock_kernel();
return 0; return 0;
} }
/* get start leaf page and index */ /* get start leaf page and index */
...@@ -3025,7 +3003,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -3025,7 +3003,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/* offset beyond directory eof ? */ /* offset beyond directory eof ? */
if (bn < 0) { if (bn < 0) {
filp->f_pos = DIREND; filp->f_pos = DIREND;
unlock_kernel();
return 0; return 0;
} }
} }
...@@ -3035,7 +3012,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -3035,7 +3012,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
DT_PUTPAGE(mp); DT_PUTPAGE(mp);
jERROR(1, ("jfs_readdir: kmalloc failed!\n")); jERROR(1, ("jfs_readdir: kmalloc failed!\n"));
filp->f_pos = DIREND; filp->f_pos = DIREND;
unlock_kernel();
return 0; return 0;
} }
while (1) { while (1) {
...@@ -3110,7 +3086,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -3110,7 +3086,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
DT_GETPAGE(ip, bn, mp, PSIZE, p, rc); DT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc) { if (rc) {
kfree(d_name); kfree(d_name);
unlock_kernel();
return -rc; return -rc;
} }
...@@ -3126,7 +3101,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -3126,7 +3101,6 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
out: out:
kfree(d_name); kfree(d_name);
DT_PUTPAGE(mp); DT_PUTPAGE(mp);
unlock_kernel();
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment