xfs: remove xfs_filestream_associate
There is no good reason to create a filestream when a directory entry is created. Delay it until the first allocation happens to simply the code and reduce the amount of mru cache lookups we do. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Родитель
1919adda07
Коммит
3b8d90766a
|
@ -318,17 +318,18 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the AG of the filestream the file or directory belongs to, or
|
* Find the right allocation group for a file, either by finding an
|
||||||
* NULLAGNUMBER otherwise.
|
* existing file stream or creating a new one.
|
||||||
|
*
|
||||||
|
* Returns NULLAGNUMBER in case of an error.
|
||||||
*/
|
*/
|
||||||
xfs_agnumber_t
|
xfs_agnumber_t
|
||||||
xfs_filestream_lookup_ag(
|
xfs_filestream_lookup_ag(
|
||||||
struct xfs_inode *ip)
|
struct xfs_inode *ip)
|
||||||
{
|
{
|
||||||
struct xfs_mount *mp = ip->i_mount;
|
struct xfs_mount *mp = ip->i_mount;
|
||||||
struct xfs_fstrm_item *item;
|
|
||||||
struct xfs_inode *pip = NULL;
|
struct xfs_inode *pip = NULL;
|
||||||
xfs_agnumber_t ag = NULLAGNUMBER;
|
xfs_agnumber_t startag, ag = NULLAGNUMBER;
|
||||||
int ref = 0;
|
int ref = 0;
|
||||||
struct xfs_mru_cache_elem *mru;
|
struct xfs_mru_cache_elem *mru;
|
||||||
|
|
||||||
|
@ -339,45 +340,13 @@ xfs_filestream_lookup_ag(
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
mru = xfs_mru_cache_lookup(mp->m_filestream, pip->i_ino);
|
mru = xfs_mru_cache_lookup(mp->m_filestream, pip->i_ino);
|
||||||
if (!mru)
|
if (mru) {
|
||||||
goto out;
|
ag = container_of(mru, struct xfs_fstrm_item, mru)->ag;
|
||||||
|
|
||||||
item = container_of(mru, struct xfs_fstrm_item, mru);
|
|
||||||
|
|
||||||
ag = item->ag;
|
|
||||||
xfs_mru_cache_done(mp->m_filestream);
|
xfs_mru_cache_done(mp->m_filestream);
|
||||||
|
|
||||||
ref = xfs_filestream_peek_ag(ip->i_mount, ag);
|
ref = xfs_filestream_peek_ag(ip->i_mount, ag);
|
||||||
out:
|
|
||||||
TRACE_LOOKUP(mp, ip, pip, ag, ref);
|
TRACE_LOOKUP(mp, ip, pip, ag, ref);
|
||||||
IRELE(pip);
|
goto out;
|
||||||
return ag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure a directory has a filestream associated with it.
|
|
||||||
*
|
|
||||||
* This is called when creating regular files in an directory that has
|
|
||||||
* filestreams enabled, so that a stream is ready by the time we need it
|
|
||||||
* in the allocator for the files inside the directory.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xfs_filestream_associate(
|
|
||||||
struct xfs_inode *pip)
|
|
||||||
{
|
|
||||||
struct xfs_mount *mp = pip->i_mount;
|
|
||||||
struct xfs_mru_cache_elem *mru;
|
|
||||||
xfs_agnumber_t startag, ag;
|
|
||||||
|
|
||||||
ASSERT(S_ISDIR(pip->i_d.di_mode));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the directory already has a file stream associated we're done.
|
|
||||||
*/
|
|
||||||
mru = xfs_mru_cache_lookup(mp->m_filestream, pip->i_ino);
|
|
||||||
if (mru) {
|
|
||||||
xfs_mru_cache_done(mp->m_filestream);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -392,7 +361,11 @@ xfs_filestream_associate(
|
||||||
} else
|
} else
|
||||||
startag = XFS_INO_TO_AGNO(mp, pip->i_ino);
|
startag = XFS_INO_TO_AGNO(mp, pip->i_ino);
|
||||||
|
|
||||||
return xfs_filestream_pick_ag(pip, startag, &ag, 0, 0);
|
if (xfs_filestream_pick_ag(pip, startag, &ag, 0, 0))
|
||||||
|
ag = NULLAGNUMBER;
|
||||||
|
out:
|
||||||
|
IRELE(pip);
|
||||||
|
return ag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -26,7 +26,6 @@ int xfs_filestream_mount(struct xfs_mount *mp);
|
||||||
void xfs_filestream_unmount(struct xfs_mount *mp);
|
void xfs_filestream_unmount(struct xfs_mount *mp);
|
||||||
void xfs_filestream_deassociate(struct xfs_inode *ip);
|
void xfs_filestream_deassociate(struct xfs_inode *ip);
|
||||||
xfs_agnumber_t xfs_filestream_lookup_ag(struct xfs_inode *ip);
|
xfs_agnumber_t xfs_filestream_lookup_ag(struct xfs_inode *ip);
|
||||||
int xfs_filestream_associate(struct xfs_inode *dip);
|
|
||||||
int xfs_filestream_new_ag(struct xfs_bmalloca *ap, xfs_agnumber_t *agp);
|
int xfs_filestream_new_ag(struct xfs_bmalloca *ap, xfs_agnumber_t *agp);
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
|
|
@ -655,7 +655,6 @@ xfs_ialloc(
|
||||||
uint flags;
|
uint flags;
|
||||||
int error;
|
int error;
|
||||||
timespec_t tv;
|
timespec_t tv;
|
||||||
int filestreams = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call the space management code to pick
|
* Call the space management code to pick
|
||||||
|
@ -772,13 +771,6 @@ xfs_ialloc(
|
||||||
flags |= XFS_ILOG_DEV;
|
flags |= XFS_ILOG_DEV;
|
||||||
break;
|
break;
|
||||||
case S_IFREG:
|
case S_IFREG:
|
||||||
/*
|
|
||||||
* we can't set up filestreams until after the VFS inode
|
|
||||||
* is set up properly.
|
|
||||||
*/
|
|
||||||
if (pip && xfs_inode_is_filestream(pip))
|
|
||||||
filestreams = 1;
|
|
||||||
/* fall through */
|
|
||||||
case S_IFDIR:
|
case S_IFDIR:
|
||||||
if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
|
if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
|
||||||
uint di_flags = 0;
|
uint di_flags = 0;
|
||||||
|
@ -844,13 +836,6 @@ xfs_ialloc(
|
||||||
/* now that we have an i_mode we can setup inode ops and unlock */
|
/* now that we have an i_mode we can setup inode ops and unlock */
|
||||||
xfs_setup_inode(ip);
|
xfs_setup_inode(ip);
|
||||||
|
|
||||||
/* now we have set up the vfs inode we can associate the filestream */
|
|
||||||
if (filestreams) {
|
|
||||||
error = xfs_filestream_associate(pip);
|
|
||||||
if (error)
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ipp = ip;
|
*ipp = ip;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче