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