10b61f8a4SDave Chinner // SPDX-License-Identifier: GPL-2.0 22a82b8beSDavid Chinner /* 32a82b8beSDavid Chinner * Copyright (c) 2006-2007 Silicon Graphics, Inc. 42cd2ef6aSChristoph Hellwig * Copyright (c) 2014 Christoph Hellwig. 52a82b8beSDavid Chinner * All Rights Reserved. 62a82b8beSDavid Chinner */ 72a82b8beSDavid Chinner #include "xfs.h" 85467b34bSDarrick J. Wong #include "xfs_shared.h" 9a4fbe6abSDave Chinner #include "xfs_format.h" 10239880efSDave Chinner #include "xfs_log_format.h" 11239880efSDave Chinner #include "xfs_trans_resv.h" 12239880efSDave Chinner #include "xfs_mount.h" 132a82b8beSDavid Chinner #include "xfs_inode.h" 142a82b8beSDavid Chinner #include "xfs_bmap.h" 152a82b8beSDavid Chinner #include "xfs_alloc.h" 162a82b8beSDavid Chinner #include "xfs_mru_cache.h" 170b1b213fSChristoph Hellwig #include "xfs_trace.h" 189bbafc71SDave Chinner #include "xfs_ag.h" 193fd129b6SDarrick J. Wong #include "xfs_ag_resv.h" 203e3673e3SBrian Foster #include "xfs_trans.h" 21f368b29bSDarrick J. Wong #include "xfs_filestream.h" 222a82b8beSDavid Chinner 232cd2ef6aSChristoph Hellwig struct xfs_fstrm_item { 2422328d71SChristoph Hellwig struct xfs_mru_cache_elem mru; 252cd2ef6aSChristoph Hellwig xfs_agnumber_t ag; /* AG in use for this directory */ 262cd2ef6aSChristoph Hellwig }; 272cd2ef6aSChristoph Hellwig 282cd2ef6aSChristoph Hellwig enum xfs_fstrm_alloc { 292cd2ef6aSChristoph Hellwig XFS_PICK_USERDATA = 1, 302cd2ef6aSChristoph Hellwig XFS_PICK_LOWSPACE = 2, 312cd2ef6aSChristoph Hellwig }; 322a82b8beSDavid Chinner 330664ce8dSChristoph Hellwig /* 340664ce8dSChristoph Hellwig * Allocation group filestream associations are tracked with per-ag atomic 352cd2ef6aSChristoph Hellwig * counters. These counters allow xfs_filestream_pick_ag() to tell whether a 36b38e0740SGao Xiang * particular AG already has active filestreams associated with it. 370664ce8dSChristoph Hellwig */ 38b94acd47SChristoph Hellwig int 390664ce8dSChristoph Hellwig xfs_filestream_peek_ag( 400664ce8dSChristoph Hellwig xfs_mount_t *mp, 410664ce8dSChristoph Hellwig xfs_agnumber_t agno) 420664ce8dSChristoph Hellwig { 430664ce8dSChristoph Hellwig struct xfs_perag *pag; 440664ce8dSChristoph Hellwig int ret; 450664ce8dSChristoph Hellwig 460664ce8dSChristoph Hellwig pag = xfs_perag_get(mp, agno); 470664ce8dSChristoph Hellwig ret = atomic_read(&pag->pagf_fstrms); 480664ce8dSChristoph Hellwig xfs_perag_put(pag); 490664ce8dSChristoph Hellwig return ret; 500664ce8dSChristoph Hellwig } 510664ce8dSChristoph Hellwig 520664ce8dSChristoph Hellwig static int 530664ce8dSChristoph Hellwig xfs_filestream_get_ag( 540664ce8dSChristoph Hellwig xfs_mount_t *mp, 550664ce8dSChristoph Hellwig xfs_agnumber_t agno) 560664ce8dSChristoph Hellwig { 570664ce8dSChristoph Hellwig struct xfs_perag *pag; 580664ce8dSChristoph Hellwig int ret; 590664ce8dSChristoph Hellwig 600664ce8dSChristoph Hellwig pag = xfs_perag_get(mp, agno); 610664ce8dSChristoph Hellwig ret = atomic_inc_return(&pag->pagf_fstrms); 620664ce8dSChristoph Hellwig xfs_perag_put(pag); 630664ce8dSChristoph Hellwig return ret; 640664ce8dSChristoph Hellwig } 650664ce8dSChristoph Hellwig 660664ce8dSChristoph Hellwig static void 670664ce8dSChristoph Hellwig xfs_filestream_put_ag( 680664ce8dSChristoph Hellwig xfs_mount_t *mp, 690664ce8dSChristoph Hellwig xfs_agnumber_t agno) 700664ce8dSChristoph Hellwig { 710664ce8dSChristoph Hellwig struct xfs_perag *pag; 720664ce8dSChristoph Hellwig 730664ce8dSChristoph Hellwig pag = xfs_perag_get(mp, agno); 740664ce8dSChristoph Hellwig atomic_dec(&pag->pagf_fstrms); 750664ce8dSChristoph Hellwig xfs_perag_put(pag); 760664ce8dSChristoph Hellwig } 772a82b8beSDavid Chinner 782cd2ef6aSChristoph Hellwig static void 792cd2ef6aSChristoph Hellwig xfs_fstrm_free_func( 807fcd3efaSChristoph Hellwig void *data, 812cd2ef6aSChristoph Hellwig struct xfs_mru_cache_elem *mru) 822cd2ef6aSChristoph Hellwig { 837fcd3efaSChristoph Hellwig struct xfs_mount *mp = data; 842cd2ef6aSChristoph Hellwig struct xfs_fstrm_item *item = 852cd2ef6aSChristoph Hellwig container_of(mru, struct xfs_fstrm_item, mru); 862cd2ef6aSChristoph Hellwig 877fcd3efaSChristoph Hellwig xfs_filestream_put_ag(mp, item->ag); 887fcd3efaSChristoph Hellwig trace_xfs_filestream_free(mp, mru->key, item->ag); 892cd2ef6aSChristoph Hellwig 901919addaSChristoph Hellwig kmem_free(item); 912cd2ef6aSChristoph Hellwig } 922cd2ef6aSChristoph Hellwig 932a82b8beSDavid Chinner /* 942a82b8beSDavid Chinner * Scan the AGs starting at startag looking for an AG that isn't in use and has 952a82b8beSDavid Chinner * at least minlen blocks free. 962a82b8beSDavid Chinner */ 972a82b8beSDavid Chinner static int 982cd2ef6aSChristoph Hellwig xfs_filestream_pick_ag( 992cd2ef6aSChristoph Hellwig struct xfs_inode *ip, 1002a82b8beSDavid Chinner xfs_agnumber_t startag, 1012a82b8beSDavid Chinner xfs_agnumber_t *agp, 1022a82b8beSDavid Chinner int flags, 1032a82b8beSDavid Chinner xfs_extlen_t minlen) 1042a82b8beSDavid Chinner { 1052cd2ef6aSChristoph Hellwig struct xfs_mount *mp = ip->i_mount; 1062cd2ef6aSChristoph Hellwig struct xfs_fstrm_item *item; 1072cd2ef6aSChristoph Hellwig struct xfs_perag *pag; 108b94acd47SChristoph Hellwig xfs_extlen_t longest, free = 0, minfree, maxfree = 0; 1092a82b8beSDavid Chinner xfs_agnumber_t ag, max_ag = NULLAGNUMBER; 1102cd2ef6aSChristoph Hellwig int err, trylock, nscan; 1112cd2ef6aSChristoph Hellwig 112c19b3b05SDave Chinner ASSERT(S_ISDIR(VFS_I(ip)->i_mode)); 1132a82b8beSDavid Chinner 1142a82b8beSDavid Chinner /* 2% of an AG's blocks must be free for it to be chosen. */ 1152a82b8beSDavid Chinner minfree = mp->m_sb.sb_agblocks / 50; 1162a82b8beSDavid Chinner 1172a82b8beSDavid Chinner ag = startag; 1182a82b8beSDavid Chinner *agp = NULLAGNUMBER; 1192a82b8beSDavid Chinner 1202a82b8beSDavid Chinner /* For the first pass, don't sleep trying to init the per-AG. */ 1212a82b8beSDavid Chinner trylock = XFS_ALLOC_FLAG_TRYLOCK; 1222a82b8beSDavid Chinner 1232a82b8beSDavid Chinner for (nscan = 0; 1; nscan++) { 1247fcd3efaSChristoph Hellwig trace_xfs_filestream_scan(mp, ip->i_ino, ag); 125b94acd47SChristoph Hellwig 1264196ac08SDave Chinner pag = xfs_perag_get(mp, ag); 1272a82b8beSDavid Chinner 1282a82b8beSDavid Chinner if (!pag->pagf_init) { 1292a82b8beSDavid Chinner err = xfs_alloc_pagf_init(mp, NULL, ag, trylock); 130f48e2df8SDarrick J. Wong if (err) { 1314196ac08SDave Chinner xfs_perag_put(pag); 132f48e2df8SDarrick J. Wong if (err != -EAGAIN) 1332a82b8beSDavid Chinner return err; 134f48e2df8SDarrick J. Wong /* Couldn't lock the AGF, skip this AG. */ 135f48e2df8SDarrick J. Wong continue; 1362a82b8beSDavid Chinner } 1374196ac08SDave Chinner } 1382a82b8beSDavid Chinner 1392a82b8beSDavid Chinner /* Keep track of the AG with the most free blocks. */ 1402a82b8beSDavid Chinner if (pag->pagf_freeblks > maxfree) { 1412a82b8beSDavid Chinner maxfree = pag->pagf_freeblks; 1422a82b8beSDavid Chinner max_ag = ag; 1432a82b8beSDavid Chinner } 1442a82b8beSDavid Chinner 1452a82b8beSDavid Chinner /* 1462a82b8beSDavid Chinner * The AG reference count does two things: it enforces mutual 1472a82b8beSDavid Chinner * exclusion when examining the suitability of an AG in this 1482a82b8beSDavid Chinner * loop, and it guards against two filestreams being established 1492a82b8beSDavid Chinner * in the same AG as each other. 1502a82b8beSDavid Chinner */ 1512a82b8beSDavid Chinner if (xfs_filestream_get_ag(mp, ag) > 1) { 1522a82b8beSDavid Chinner xfs_filestream_put_ag(mp, ag); 1532a82b8beSDavid Chinner goto next_ag; 1542a82b8beSDavid Chinner } 1552a82b8beSDavid Chinner 156a1f69417SEric Sandeen longest = xfs_alloc_longest_free_extent(pag, 1573fd129b6SDarrick J. Wong xfs_alloc_min_freelist(mp, pag), 1583fd129b6SDarrick J. Wong xfs_ag_resv_needed(pag, XFS_AG_RESV_NONE)); 1592a82b8beSDavid Chinner if (((minlen && longest >= minlen) || 1602a82b8beSDavid Chinner (!minlen && pag->pagf_freeblks >= minfree)) && 1612a82b8beSDavid Chinner (!pag->pagf_metadata || !(flags & XFS_PICK_USERDATA) || 1622a82b8beSDavid Chinner (flags & XFS_PICK_LOWSPACE))) { 1632a82b8beSDavid Chinner 1642a82b8beSDavid Chinner /* Break out, retaining the reference on the AG. */ 1652a82b8beSDavid Chinner free = pag->pagf_freeblks; 1664196ac08SDave Chinner xfs_perag_put(pag); 1672a82b8beSDavid Chinner *agp = ag; 1682a82b8beSDavid Chinner break; 1692a82b8beSDavid Chinner } 1702a82b8beSDavid Chinner 1712a82b8beSDavid Chinner /* Drop the reference on this AG, it's not usable. */ 1722a82b8beSDavid Chinner xfs_filestream_put_ag(mp, ag); 1732a82b8beSDavid Chinner next_ag: 1744196ac08SDave Chinner xfs_perag_put(pag); 1752a82b8beSDavid Chinner /* Move to the next AG, wrapping to AG 0 if necessary. */ 1762a82b8beSDavid Chinner if (++ag >= mp->m_sb.sb_agcount) 1772a82b8beSDavid Chinner ag = 0; 1782a82b8beSDavid Chinner 1792a82b8beSDavid Chinner /* If a full pass of the AGs hasn't been done yet, continue. */ 1802a82b8beSDavid Chinner if (ag != startag) 1812a82b8beSDavid Chinner continue; 1822a82b8beSDavid Chinner 1832a82b8beSDavid Chinner /* Allow sleeping in xfs_alloc_pagf_init() on the 2nd pass. */ 1842a82b8beSDavid Chinner if (trylock != 0) { 1852a82b8beSDavid Chinner trylock = 0; 1862a82b8beSDavid Chinner continue; 1872a82b8beSDavid Chinner } 1882a82b8beSDavid Chinner 1892a82b8beSDavid Chinner /* Finally, if lowspace wasn't set, set it for the 3rd pass. */ 1902a82b8beSDavid Chinner if (!(flags & XFS_PICK_LOWSPACE)) { 1912a82b8beSDavid Chinner flags |= XFS_PICK_LOWSPACE; 1922a82b8beSDavid Chinner continue; 1932a82b8beSDavid Chinner } 1942a82b8beSDavid Chinner 1952a82b8beSDavid Chinner /* 1962a82b8beSDavid Chinner * Take the AG with the most free space, regardless of whether 1972a82b8beSDavid Chinner * it's already in use by another filestream. 1982a82b8beSDavid Chinner */ 1992a82b8beSDavid Chinner if (max_ag != NULLAGNUMBER) { 2002a82b8beSDavid Chinner xfs_filestream_get_ag(mp, max_ag); 2012a82b8beSDavid Chinner free = maxfree; 2022a82b8beSDavid Chinner *agp = max_ag; 2032a82b8beSDavid Chinner break; 2042a82b8beSDavid Chinner } 2052a82b8beSDavid Chinner 2062a82b8beSDavid Chinner /* take AG 0 if none matched */ 207b94acd47SChristoph Hellwig trace_xfs_filestream_pick(ip, *agp, free, nscan); 2082a82b8beSDavid Chinner *agp = 0; 2092a82b8beSDavid Chinner return 0; 2102a82b8beSDavid Chinner } 2112a82b8beSDavid Chinner 212b94acd47SChristoph Hellwig trace_xfs_filestream_pick(ip, *agp, free, nscan); 2132a82b8beSDavid Chinner 2142cd2ef6aSChristoph Hellwig if (*agp == NULLAGNUMBER) 2152a82b8beSDavid Chinner return 0; 2162a82b8beSDavid Chinner 2172451337dSDave Chinner err = -ENOMEM; 2181919addaSChristoph Hellwig item = kmem_alloc(sizeof(*item), KM_MAYFAIL); 2192a82b8beSDavid Chinner if (!item) 2202cd2ef6aSChristoph Hellwig goto out_put_ag; 2212a82b8beSDavid Chinner 2222cd2ef6aSChristoph Hellwig item->ag = *agp; 2232a82b8beSDavid Chinner 22422328d71SChristoph Hellwig err = xfs_mru_cache_insert(mp->m_filestream, ip->i_ino, &item->mru); 2252a82b8beSDavid Chinner if (err) { 2262451337dSDave Chinner if (err == -EEXIST) 2272cd2ef6aSChristoph Hellwig err = 0; 2282cd2ef6aSChristoph Hellwig goto out_free_item; 2292cd2ef6aSChristoph Hellwig } 2302cd2ef6aSChristoph Hellwig 2312cd2ef6aSChristoph Hellwig return 0; 2322cd2ef6aSChristoph Hellwig 2332cd2ef6aSChristoph Hellwig out_free_item: 2341919addaSChristoph Hellwig kmem_free(item); 2352cd2ef6aSChristoph Hellwig out_put_ag: 2362cd2ef6aSChristoph Hellwig xfs_filestream_put_ag(mp, *agp); 2372a82b8beSDavid Chinner return err; 2382a82b8beSDavid Chinner } 2392a82b8beSDavid Chinner 2402cd2ef6aSChristoph Hellwig static struct xfs_inode * 2412cd2ef6aSChristoph Hellwig xfs_filestream_get_parent( 2422cd2ef6aSChristoph Hellwig struct xfs_inode *ip) 2432a82b8beSDavid Chinner { 2442cd2ef6aSChristoph Hellwig struct inode *inode = VFS_I(ip), *dir = NULL; 2452cd2ef6aSChristoph Hellwig struct dentry *dentry, *parent; 2462a82b8beSDavid Chinner 2472cd2ef6aSChristoph Hellwig dentry = d_find_alias(inode); 2482cd2ef6aSChristoph Hellwig if (!dentry) 2492cd2ef6aSChristoph Hellwig goto out; 2502a82b8beSDavid Chinner 2512cd2ef6aSChristoph Hellwig parent = dget_parent(dentry); 2522cd2ef6aSChristoph Hellwig if (!parent) 2532cd2ef6aSChristoph Hellwig goto out_dput; 2542a82b8beSDavid Chinner 2552b0143b5SDavid Howells dir = igrab(d_inode(parent)); 2562cd2ef6aSChristoph Hellwig dput(parent); 2572a82b8beSDavid Chinner 2582cd2ef6aSChristoph Hellwig out_dput: 2592cd2ef6aSChristoph Hellwig dput(dentry); 2602cd2ef6aSChristoph Hellwig out: 2612cd2ef6aSChristoph Hellwig return dir ? XFS_I(dir) : NULL; 2622a82b8beSDavid Chinner } 2632a82b8beSDavid Chinner 2642a82b8beSDavid Chinner /* 2653b8d9076SChristoph Hellwig * Find the right allocation group for a file, either by finding an 2663b8d9076SChristoph Hellwig * existing file stream or creating a new one. 2673b8d9076SChristoph Hellwig * 2683b8d9076SChristoph Hellwig * Returns NULLAGNUMBER in case of an error. 2692a82b8beSDavid Chinner */ 2702a82b8beSDavid Chinner xfs_agnumber_t 2712a82b8beSDavid Chinner xfs_filestream_lookup_ag( 2722cd2ef6aSChristoph Hellwig struct xfs_inode *ip) 2732a82b8beSDavid Chinner { 27422328d71SChristoph Hellwig struct xfs_mount *mp = ip->i_mount; 2752cd2ef6aSChristoph Hellwig struct xfs_inode *pip = NULL; 2763b8d9076SChristoph Hellwig xfs_agnumber_t startag, ag = NULLAGNUMBER; 27722328d71SChristoph Hellwig struct xfs_mru_cache_elem *mru; 2782a82b8beSDavid Chinner 279c19b3b05SDave Chinner ASSERT(S_ISREG(VFS_I(ip)->i_mode)); 2802a82b8beSDavid Chinner 2812cd2ef6aSChristoph Hellwig pip = xfs_filestream_get_parent(ip); 2822cd2ef6aSChristoph Hellwig if (!pip) 283b26384dcSEric Sandeen return NULLAGNUMBER; 2842a82b8beSDavid Chinner 2852cd2ef6aSChristoph Hellwig mru = xfs_mru_cache_lookup(mp->m_filestream, pip->i_ino); 2863b8d9076SChristoph Hellwig if (mru) { 2873b8d9076SChristoph Hellwig ag = container_of(mru, struct xfs_fstrm_item, mru)->ag; 28822328d71SChristoph Hellwig xfs_mru_cache_done(mp->m_filestream); 2892a82b8beSDavid Chinner 2907fcd3efaSChristoph Hellwig trace_xfs_filestream_lookup(mp, ip->i_ino, ag); 2913b8d9076SChristoph Hellwig goto out; 2922a82b8beSDavid Chinner } 2932a82b8beSDavid Chinner 2942a82b8beSDavid Chinner /* 2952a82b8beSDavid Chinner * Set the starting AG using the rotor for inode32, otherwise 2962a82b8beSDavid Chinner * use the directory inode's AG. 2972a82b8beSDavid Chinner */ 298*2e973b2cSDave Chinner if (xfs_is_inode32(mp)) { 2992cd2ef6aSChristoph Hellwig xfs_agnumber_t rotorstep = xfs_rotorstep; 3002a82b8beSDavid Chinner startag = (mp->m_agfrotor / rotorstep) % mp->m_sb.sb_agcount; 3012a82b8beSDavid Chinner mp->m_agfrotor = (mp->m_agfrotor + 1) % 3022a82b8beSDavid Chinner (mp->m_sb.sb_agcount * rotorstep); 3032a82b8beSDavid Chinner } else 3042a82b8beSDavid Chinner startag = XFS_INO_TO_AGNO(mp, pip->i_ino); 3052a82b8beSDavid Chinner 3063b8d9076SChristoph Hellwig if (xfs_filestream_pick_ag(pip, startag, &ag, 0, 0)) 3073b8d9076SChristoph Hellwig ag = NULLAGNUMBER; 3083b8d9076SChristoph Hellwig out: 30944a8736bSDarrick J. Wong xfs_irele(pip); 3103b8d9076SChristoph Hellwig return ag; 3112a82b8beSDavid Chinner } 3122a82b8beSDavid Chinner 3132a82b8beSDavid Chinner /* 3142cd2ef6aSChristoph Hellwig * Pick a new allocation group for the current file and its file stream. 3152cd2ef6aSChristoph Hellwig * 3162cd2ef6aSChristoph Hellwig * This is called when the allocator can't find a suitable extent in the 3172cd2ef6aSChristoph Hellwig * current AG, and we have to move the stream into a new AG with more space. 3182a82b8beSDavid Chinner */ 3192a82b8beSDavid Chinner int 3202a82b8beSDavid Chinner xfs_filestream_new_ag( 32168988114SDave Chinner struct xfs_bmalloca *ap, 3222a82b8beSDavid Chinner xfs_agnumber_t *agp) 3232a82b8beSDavid Chinner { 3242cd2ef6aSChristoph Hellwig struct xfs_inode *ip = ap->ip, *pip; 3252cd2ef6aSChristoph Hellwig struct xfs_mount *mp = ip->i_mount; 3262cd2ef6aSChristoph Hellwig xfs_extlen_t minlen = ap->length; 3272cd2ef6aSChristoph Hellwig xfs_agnumber_t startag = 0; 328292378edSDave Chinner int flags = 0; 329292378edSDave Chinner int err = 0; 3302cd2ef6aSChristoph Hellwig struct xfs_mru_cache_elem *mru; 3312a82b8beSDavid Chinner 3322a82b8beSDavid Chinner *agp = NULLAGNUMBER; 3332a82b8beSDavid Chinner 3342cd2ef6aSChristoph Hellwig pip = xfs_filestream_get_parent(ip); 3352cd2ef6aSChristoph Hellwig if (!pip) 3362cd2ef6aSChristoph Hellwig goto exit; 3372cd2ef6aSChristoph Hellwig 3382cd2ef6aSChristoph Hellwig mru = xfs_mru_cache_remove(mp->m_filestream, pip->i_ino); 33922328d71SChristoph Hellwig if (mru) { 3402cd2ef6aSChristoph Hellwig struct xfs_fstrm_item *item = 3412cd2ef6aSChristoph Hellwig container_of(mru, struct xfs_fstrm_item, mru); 3422cd2ef6aSChristoph Hellwig startag = (item->ag + 1) % mp->m_sb.sb_agcount; 3432a82b8beSDavid Chinner } 3442a82b8beSDavid Chinner 345c34d570dSChristoph Hellwig if (ap->datatype & XFS_ALLOC_USERDATA) 346292378edSDave Chinner flags |= XFS_PICK_USERDATA; 3471214f1cfSBrian Foster if (ap->tp->t_flags & XFS_TRANS_LOWMODE) 348292378edSDave Chinner flags |= XFS_PICK_LOWSPACE; 3492a82b8beSDavid Chinner 3502cd2ef6aSChristoph Hellwig err = xfs_filestream_pick_ag(pip, startag, agp, flags, minlen); 3512a82b8beSDavid Chinner 3522a82b8beSDavid Chinner /* 3532cd2ef6aSChristoph Hellwig * Only free the item here so we skip over the old AG earlier. 3542a82b8beSDavid Chinner */ 3552cd2ef6aSChristoph Hellwig if (mru) 3567fcd3efaSChristoph Hellwig xfs_fstrm_free_func(mp, mru); 3572a82b8beSDavid Chinner 35844a8736bSDarrick J. Wong xfs_irele(pip); 3592a82b8beSDavid Chinner exit: 3602cd2ef6aSChristoph Hellwig if (*agp == NULLAGNUMBER) 3612a82b8beSDavid Chinner *agp = 0; 3622a82b8beSDavid Chinner return err; 3632a82b8beSDavid Chinner } 3642a82b8beSDavid Chinner 3652a82b8beSDavid Chinner void 3662a82b8beSDavid Chinner xfs_filestream_deassociate( 3672cd2ef6aSChristoph Hellwig struct xfs_inode *ip) 3682a82b8beSDavid Chinner { 36922328d71SChristoph Hellwig xfs_mru_cache_delete(ip->i_mount->m_filestream, ip->i_ino); 3702a82b8beSDavid Chinner } 3712cd2ef6aSChristoph Hellwig 3722cd2ef6aSChristoph Hellwig int 3732cd2ef6aSChristoph Hellwig xfs_filestream_mount( 3742cd2ef6aSChristoph Hellwig xfs_mount_t *mp) 3752cd2ef6aSChristoph Hellwig { 3762cd2ef6aSChristoph Hellwig /* 3772cd2ef6aSChristoph Hellwig * The filestream timer tunable is currently fixed within the range of 3782cd2ef6aSChristoph Hellwig * one second to four minutes, with five seconds being the default. The 3792cd2ef6aSChristoph Hellwig * group count is somewhat arbitrary, but it'd be nice to adhere to the 3802cd2ef6aSChristoph Hellwig * timer tunable to within about 10 percent. This requires at least 10 3812cd2ef6aSChristoph Hellwig * groups. 3822cd2ef6aSChristoph Hellwig */ 3837fcd3efaSChristoph Hellwig return xfs_mru_cache_create(&mp->m_filestream, mp, 3847fcd3efaSChristoph Hellwig xfs_fstrm_centisecs * 10, 10, xfs_fstrm_free_func); 3852cd2ef6aSChristoph Hellwig } 3862cd2ef6aSChristoph Hellwig 3872cd2ef6aSChristoph Hellwig void 3882cd2ef6aSChristoph Hellwig xfs_filestream_unmount( 3892cd2ef6aSChristoph Hellwig xfs_mount_t *mp) 3902cd2ef6aSChristoph Hellwig { 3912cd2ef6aSChristoph Hellwig xfs_mru_cache_destroy(mp->m_filestream); 3922cd2ef6aSChristoph Hellwig } 393