Back in January we had a problem of NFSv2 not showing the last directory
entry when used ontop of JFS.
I think the problem is that somehow NFSv2 needs a file offset to be
storable in a 32bit signed integer. The below patch makes JFS use
INT_MAX as magic file position as end-of-directory marker and thus
fixes NFSv2 readdir(). It does artificially limit JFS to 2GB
directories, but as this is an implementation and not format issue,
I think it's ok to live with.
Christoph
--
Of course it doesn't work. We've performed a software upgrade.
Index: fs/jfs/jfs_dtree.c
===================================================================
RCS file: /usr/cvs/jfs/linux24/fs/jfs/jfs_dtree.c,v
retrieving revision 1.25
diff -u -u -r1.25 jfs_dtree.c
--- fs/jfs/jfs_dtree.c 2002/02/19 21:26:15 1.25
+++ fs/jfs/jfs_dtree.c 2002/02/22 15:08:39
@@ -2869,7 +2869,7 @@
int do_index = 0;
uint loop_count = 0;
- if (filp->f_pos == -1)
+ if (filp->f_pos == DIREND)
return 0;
if (DO_INDEX(ip)) {
@@ -2888,25 +2888,25 @@
dir_table_slot_t dirtab_slot;
if (dtEmpty(ip)) {
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
return 0;
}
repeat:
rc = get_index(ip, dir_index, &dirtab_slot);
if (rc) {
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
return rc;
}
if (dirtab_slot.flag == DIR_INDEX_FREE) {
if (loop_count++ > JFS_IP(ip)->next_index) {
jERROR(1, ("jfs_readdir detected "
"infinite loop!\n"));
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
return 0;
}
dir_index = le32_to_cpu(dirtab_slot.addr2);
if (dir_index == -1) {
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
return 0;
}
goto repeat;
@@ -2915,7 +2915,7 @@
index = dirtab_slot.slot;
DT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc) {
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
return 0;
}
if (p->header.flag & BT_INTERNAL) {
@@ -2946,7 +2946,7 @@
* Find first entry of left-most leaf
*/
if (dtEmpty(ip)) {
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
return 0;
}
@@ -2991,7 +2991,7 @@
}
if (dtEmpty(ip)) {
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
return 0;
}
@@ -2999,7 +2999,7 @@
jERROR(1,
("jfs_readdir: unexpected rc = %d from dtReadNext\n",
rc));
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
return 0;
}
/* get start leaf page and index */
@@ -3007,7 +3007,7 @@
/* offset beyond directory eof ? */
if (bn < 0) {
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
return 0;
}
}
@@ -3016,7 +3016,7 @@
if (d_name == NULL) {
DT_PUTPAGE(mp);
jERROR(1, ("jfs_readdir: kmalloc failed!\n"));
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
return 0;
}
while (1) {
@@ -3065,13 +3065,13 @@
*/
if (p->header.flag & BT_ROOT) {
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
break;
}
bn = le64_to_cpu(p->header.next);
if (bn == 0) {
- filp->f_pos = -1;
+ filp->f_pos = DIREND;
break;
}
Index: fs/jfs/jfs_dtree.h
===================================================================
RCS file: /usr/cvs/jfs/linux24/fs/jfs/jfs_dtree.h,v
retrieving revision 1.1
diff -u -u -r1.1 jfs_dtree.h
--- fs/jfs/jfs_dtree.h 2002/02/12 15:18:20 1.1
+++ fs/jfs/jfs_dtree.h 2002/02/22 15:08:40
@@ -252,6 +252,10 @@
#define DIRENTSIZ(namlen) \
( (sizeof(struct dirent) - 2*(JFS_NAME_MAX+1) + 2*((namlen)+1) + 3) &~ 3 )
+/*
+ * Maximum file offset for directories.
+ */
+#define DIREND INT_MAX
/*
* external declarations
_______________________________________________
Jfs-discussion mailing list
[EMAIL PROTECTED]
http://www-124.ibm.com/developerworks/oss/mailman/listinfo/jfs-discussion