Commit ba662e50 authored by Stephen Lord's avatar Stephen Lord

[XFS] rework readdir to be closer to the irix model internally, do all

the filldir fixup at the linvfs layer. This is the V2 directory
component, the V1 code still needs fixing up. We now return the
same directory offsets as Irix does.

SGI Modid: 2.5.x-xfs:slinx:134646a
parent 10c2f9b1
......@@ -227,8 +227,8 @@ linvfs_readdir(
int eof = 0;
caddr_t read_buf;
int namelen, size = 0;
size_t rlen = PAGE_CACHE_SIZE << 2;
xfs_off_t start_offset;
size_t rlen = PAGE_CACHE_SIZE;
xfs_off_t start_offset, curr_offset;
xfs_dirent_t *dbp = NULL;
vp = LINVFS_GET_VP(filp->f_dentry->d_inode);
......@@ -247,7 +247,7 @@ linvfs_readdir(
uio.uio_iov = &iov;
uio.uio_fmode = filp->f_mode;
uio.uio_segflg = UIO_SYSSPACE;
uio.uio_offset = filp->f_pos;
curr_offset = uio.uio_offset = filp->f_pos;
while (!eof) {
uio.uio_resid = iov.iov_len = rlen;
......@@ -268,12 +268,13 @@ linvfs_readdir(
namelen = strlen(dbp->d_name);
if (filldir(dirent, dbp->d_name, namelen,
(loff_t) dbp->d_off,
(loff_t) curr_offset,
(ino_t) dbp->d_ino,
DT_UNKNOWN)) {
goto done;
}
size -= dbp->d_reclen;
curr_offset = (loff_t)dbp->d_off;
dbp = nextdp(dbp);
}
}
......@@ -282,7 +283,7 @@ linvfs_readdir(
if (size == 0)
filp->f_pos = uio.uio_offset;
else if (dbp)
filp->f_pos = dbp->d_off;
filp->f_pos = curr_offset;
}
kfree(read_buf);
......
......@@ -488,8 +488,6 @@ xfs_dir2_block_getdents(
dep = (xfs_dir2_data_entry_t *)ptr;
savptr = ptr; /* In case we need it.. */
/*
* Bump pointer for the next iteration.
*/
......@@ -504,14 +502,8 @@ xfs_dir2_block_getdents(
*/
p.namelen = dep->namelen;
/*
* NOTE! Linux "filldir" semantics require that the
* offset "cookie" be for this entry, not the
* next; all the actual shuffling to make it
* "look right" to the user is done in filldir.
*/
p.cook = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk,
savptr - (char *)block);
ptr - (char *)block);
#if XFS_BIG_FILESYSTEMS
p.ino = INT_GET(dep->inumber, ARCH_CONVERT) + mp->m_inoadd;
#else
......
......@@ -1086,13 +1086,7 @@ xfs_dir2_leaf_getdents(
length = XFS_DIR2_DATA_ENTSIZE(p.namelen);
/*
* NOTE! Linux "filldir" semantics require that the
* offset "cookie" be for this entry, not the
* next; all the actual shuffling to make it
* "look right" to the user is done in filldir.
*/
p.cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff);
p.cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff + length);
#if XFS_BIG_FILESYSTEMS
p.ino = INT_GET(dep->inumber, ARCH_CONVERT) + mp->m_inoadd;
......
......@@ -752,14 +752,8 @@ xfs_dir2_sf_getdents(
if (dir_offset <=
XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk,
XFS_DIR2_DATA_DOT_OFFSET)) {
/*
* NOTE! Linux "filldir" semantics require that the
* offset "cookie" be for this entry, not the
* next; all the actual shuffling to make it
* "look right" to the user is done in filldir.
*/
p.cook = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, 0,
XFS_DIR2_DATA_DOT_OFFSET);
XFS_DIR2_DATA_DOTDOT_OFFSET);
#if XFS_BIG_FILESYSTEMS
p.ino = dp->i_ino + mp->m_inoadd;
#else
......@@ -784,14 +778,8 @@ xfs_dir2_sf_getdents(
if (dir_offset <=
XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk,
XFS_DIR2_DATA_DOTDOT_OFFSET)) {
/*
* NOTE! Linux "filldir" semantics require that the
* offset "cookie" be for this entry, not the
* next; all the actual shuffling to make it
* "look right" to the user is done in filldir.
*/
p.cook = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk,
XFS_DIR2_DATA_DOTDOT_OFFSET);
XFS_DIR2_DATA_FIRST_OFFSET);
#if XFS_BIG_FILESYSTEMS
p.ino = XFS_DIR2_SF_GET_INUMBER_ARCH(sfp, &sfp->hdr.parent, ARCH_CONVERT) +
mp->m_inoadd;
......@@ -826,14 +814,9 @@ xfs_dir2_sf_getdents(
p.namelen = sfep->namelen;
/*
* NOTE! Linux "filldir" semantics require that the
* offset "cookie" be for this entry, not the
* next; all the actual shuffling to make it
* "look right" to the user is done in filldir.
*/
p.cook = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk,
XFS_DIR2_SF_GET_OFFSET_ARCH(sfep, ARCH_CONVERT));
XFS_DIR2_SF_GET_OFFSET_ARCH(sfep, ARCH_CONVERT) +
XFS_DIR2_DATA_ENTSIZE(p.namelen));
#if XFS_BIG_FILESYSTEMS
p.ino = XFS_DIR2_SF_GET_INUMBER_ARCH(sfp,
......
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