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