Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christoph Hellwig and committed by
Dave Chinner
3b8d9076 1919adda

+15 -58
+15 -42
fs/xfs/xfs_filestream.c
··· 318 318 } 319 319 320 320 /* 321 - * Return the AG of the filestream the file or directory belongs to, or 322 - * NULLAGNUMBER otherwise. 321 + * Find the right allocation group for a file, either by finding an 322 + * existing file stream or creating a new one. 323 + * 324 + * Returns NULLAGNUMBER in case of an error. 323 325 */ 324 326 xfs_agnumber_t 325 327 xfs_filestream_lookup_ag( 326 328 struct xfs_inode *ip) 327 329 { 328 330 struct xfs_mount *mp = ip->i_mount; 329 - struct xfs_fstrm_item *item; 330 331 struct xfs_inode *pip = NULL; 331 - xfs_agnumber_t ag = NULLAGNUMBER; 332 + xfs_agnumber_t startag, ag = NULLAGNUMBER; 332 333 int ref = 0; 333 334 struct xfs_mru_cache_elem *mru; 334 335 ··· 340 339 goto out; 341 340 342 341 mru = xfs_mru_cache_lookup(mp->m_filestream, pip->i_ino); 343 - if (!mru) 344 - goto out; 345 - 346 - item = container_of(mru, struct xfs_fstrm_item, mru); 347 - 348 - ag = item->ag; 349 - xfs_mru_cache_done(mp->m_filestream); 350 - 351 - ref = xfs_filestream_peek_ag(ip->i_mount, ag); 352 - out: 353 - TRACE_LOOKUP(mp, ip, pip, ag, ref); 354 - IRELE(pip); 355 - return ag; 356 - } 357 - 358 - /* 359 - * Make sure a directory has a filestream associated with it. 360 - * 361 - * This is called when creating regular files in an directory that has 362 - * filestreams enabled, so that a stream is ready by the time we need it 363 - * in the allocator for the files inside the directory. 364 - */ 365 - int 366 - xfs_filestream_associate( 367 - struct xfs_inode *pip) 368 - { 369 - struct xfs_mount *mp = pip->i_mount; 370 - struct xfs_mru_cache_elem *mru; 371 - xfs_agnumber_t startag, ag; 372 - 373 - ASSERT(S_ISDIR(pip->i_d.di_mode)); 374 - 375 - /* 376 - * If the directory already has a file stream associated we're done. 377 - */ 378 - mru = xfs_mru_cache_lookup(mp->m_filestream, pip->i_ino); 379 342 if (mru) { 343 + ag = container_of(mru, struct xfs_fstrm_item, mru)->ag; 380 344 xfs_mru_cache_done(mp->m_filestream); 381 - return 0; 345 + 346 + ref = xfs_filestream_peek_ag(ip->i_mount, ag); 347 + TRACE_LOOKUP(mp, ip, pip, ag, ref); 348 + goto out; 382 349 } 383 350 384 351 /* ··· 361 392 } else 362 393 startag = XFS_INO_TO_AGNO(mp, pip->i_ino); 363 394 364 - return xfs_filestream_pick_ag(pip, startag, &ag, 0, 0); 395 + if (xfs_filestream_pick_ag(pip, startag, &ag, 0, 0)) 396 + ag = NULLAGNUMBER; 397 + out: 398 + IRELE(pip); 399 + return ag; 365 400 } 366 401 367 402 /*
-1
fs/xfs/xfs_filestream.h
··· 26 26 void xfs_filestream_unmount(struct xfs_mount *mp); 27 27 void xfs_filestream_deassociate(struct xfs_inode *ip); 28 28 xfs_agnumber_t xfs_filestream_lookup_ag(struct xfs_inode *ip); 29 - int xfs_filestream_associate(struct xfs_inode *dip); 30 29 int xfs_filestream_new_ag(struct xfs_bmalloca *ap, xfs_agnumber_t *agp); 31 30 32 31 static inline int
-15
fs/xfs/xfs_inode.c
··· 655 655 uint flags; 656 656 int error; 657 657 timespec_t tv; 658 - int filestreams = 0; 659 658 660 659 /* 661 660 * Call the space management code to pick ··· 771 772 flags |= XFS_ILOG_DEV; 772 773 break; 773 774 case S_IFREG: 774 - /* 775 - * we can't set up filestreams until after the VFS inode 776 - * is set up properly. 777 - */ 778 - if (pip && xfs_inode_is_filestream(pip)) 779 - filestreams = 1; 780 - /* fall through */ 781 775 case S_IFDIR: 782 776 if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) { 783 777 uint di_flags = 0; ··· 835 843 836 844 /* now that we have an i_mode we can setup inode ops and unlock */ 837 845 xfs_setup_inode(ip); 838 - 839 - /* now we have set up the vfs inode we can associate the filestream */ 840 - if (filestreams) { 841 - error = xfs_filestream_associate(pip); 842 - if (error) 843 - return error; 844 - } 845 846 846 847 *ipp = ip; 847 848 return 0;