[XFS] Dynamically allocate xfs_dir2_put_args_t structure to reduce stack

pressure in xfs_dir2_leaf_getdents routine.

SGI-PV: 947312
SGI-Modid: xfs-linux-melb:xfs-kern:25359a

Signed-off-by: Nathan Scott <nathans@sgi.com>
This commit is contained in:
Nathan Scott 2006-03-14 13:32:24 +11:00
parent 1f6553f9f9
commit f6d75cbed9

View file

@ -778,7 +778,7 @@ xfs_dir2_leaf_getdents(
xfs_mount_t *mp; /* filesystem mount point */ xfs_mount_t *mp; /* filesystem mount point */
xfs_dir2_off_t newoff; /* new curoff after new blk */ xfs_dir2_off_t newoff; /* new curoff after new blk */
int nmap; /* mappings to ask xfs_bmapi */ int nmap; /* mappings to ask xfs_bmapi */
xfs_dir2_put_args_t p; /* formatting arg bundle */ xfs_dir2_put_args_t *p; /* formatting arg bundle */
char *ptr = NULL; /* pointer to current data */ char *ptr = NULL; /* pointer to current data */
int ra_current; /* number of read-ahead blks */ int ra_current; /* number of read-ahead blks */
int ra_index; /* *map index for read-ahead */ int ra_index; /* *map index for read-ahead */
@ -797,9 +797,10 @@ xfs_dir2_leaf_getdents(
/* /*
* Setup formatting arguments. * Setup formatting arguments.
*/ */
p.dbp = dbp; p = kmem_alloc(sizeof(*p), KM_SLEEP);
p.put = put; p->dbp = dbp;
p.uio = uio; p->put = put;
p->uio = uio;
/* /*
* Set up to bmap a number of blocks based on the caller's * Set up to bmap a number of blocks based on the caller's
* buffer size, the directory block size, and the filesystem * buffer size, the directory block size, and the filesystem
@ -1092,24 +1093,24 @@ xfs_dir2_leaf_getdents(
*/ */
dep = (xfs_dir2_data_entry_t *)ptr; dep = (xfs_dir2_data_entry_t *)ptr;
p.namelen = dep->namelen; p->namelen = dep->namelen;
length = XFS_DIR2_DATA_ENTSIZE(p.namelen); length = XFS_DIR2_DATA_ENTSIZE(p->namelen);
p.cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff + length); p->cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff + length);
p.ino = INT_GET(dep->inumber, ARCH_CONVERT); p->ino = INT_GET(dep->inumber, ARCH_CONVERT);
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
p.ino += mp->m_inoadd; p->ino += mp->m_inoadd;
#endif #endif
p.name = (char *)dep->name; p->name = (char *)dep->name;
error = p.put(&p); error = p->put(p);
/* /*
* Won't fit. Return to caller. * Won't fit. Return to caller.
*/ */
if (!p.done) { if (!p->done) {
eof = 0; eof = 0;
break; break;
} }
@ -1129,6 +1130,7 @@ xfs_dir2_leaf_getdents(
else else
uio->uio_offset = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff); uio->uio_offset = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff);
kmem_free(map, map_size * sizeof(*map)); kmem_free(map, map_size * sizeof(*map));
kmem_free(p, sizeof(*p));
if (bp) if (bp)
xfs_da_brelse(tp, bp); xfs_da_brelse(tp, bp);
return error; return error;