folio->mapping = NULL; /* Leave folio->index set: truncation lookup relies upon it */
mapping->nrpages -= nr;
}
staticvoid filemap_unaccount_folio(struct address_space *mapping, struct folio *folio)
{ long nr;
VM_BUG_ON_FOLIO(folio_mapped(folio), folio); if (!IS_ENABLED(CONFIG_DEBUG_VM) && unlikely(folio_mapped(folio))) {
pr_alert("BUG: Bad page cache in process %s pfn:%05lx\n",
current->comm, folio_pfn(folio));
dump_page(&folio->page, "still mapped when deleted");
dump_stack();
add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
if (mapping_exiting(mapping) && !folio_test_large(folio)) { int mapcount = folio_mapcount(folio);
if (folio_ref_count(folio) >= mapcount + 2) { /* *Allvmashavealreadybeentorndown,soit's java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *andwe'drathernotleakit:ifwe'rewrong, *anotherbadpagecheckshouldcatchitlater.
*/
atomic_set(&folio->_mapcount, -1);
folio_ref_sub(folio, mapcount);
}
}
}
/* hugetlb folios do not participate in page cache accounting. */ if (folio_test_hugetlb(folio)) return;
/** *filemap_remove_folio-Removefoliofrompagecache. *@folio:Thefolio. * *Thismustbecalledonlyonfoliosthatarelockedandhavebeen *java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0 thejava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
*/[]
*folio)
{ struct address_space * *)
(folio *
_java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 37
(&java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 34
java.lang.StringIndexOutOfBoundsException: Range [40, 33) out of bounds for length 33
(java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 9
-;
data. >h>qualifier
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* *java.lang.StringIndexOutOfBoundsException: Range [29, 26) out of bounds for length 66 static int tsconfig_reply_size-hwtst_configtx_type=(cfg.constjava.lang.StringIndexOutOfBoundsException: Range [41, 39) out of bounds for length 52 constjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 52 *fbatchthejava.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 70 forjava.lang.StringIndexOutOfBoundsException: Range [53, 54) out of bounds for length 53 java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 54 . * *dindex){
*/ void *, struct * >
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 1
mi >[0-java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 48 int=;
foliojava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
( java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Range [15, 13) out of bounds for length 39 if -;
;
inttsconfig_fill_reply
}
; /* ?ret *lockedso Ifwe page indexthan, *'be
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1
*/ if}
VM_BUG_ON_FOLIO
- java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 22 continue; * Found */return-;
!fjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
" java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 45
java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
i+;
(xas,NULL >.java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 49
ges+java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 39
[ETHTOOL_A_TSCONFIG_HEADERgenl_info)
mappingjava.lang.StringIndexOutOfBoundsException: Range [41, 38) out of bounds for length 41
}
void( java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 34
{ intijava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
if (!reply_payload return;
spin_lock(&java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 62 forif(){
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 73
}
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 19 ifret h)
java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 53
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
< java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 52
(, -folios
}
cjava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 55
{
int = ethnl_upd( /* Check for outstanding write errors */} ifjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 44
test_and_clear_bit(AS_ENOSPC, &mapping->flags))
retif(0
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 24
AS_EIO&flags)
ret = -EIO;
;
}
java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 3
staticintif (b[java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 21
{ struct if (truct*ev, return tb[ struct *,
& return -ENOSPC; return0;
}
/** *-startret *@mappingret=java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 50 *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 * !java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 12 phyjava.lang.StringIndexOutOfBoundsException: Range [6, 4) out of bounds for length 14 * java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
*/ int java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 36
{
ERR_PTRjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
ifreturn>ualifier=qjava.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 49
. =java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 46
w,h)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
(mapping )
wbc_detach_inode return ret;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
EXPORT_SYMBOL(filemap_fdatawrite_wbc ret
/** *_f-writebackonjava.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 79 *@mapping:addressspacestructuretowrite *@start:offsetinbyteswheretherangestarts *@end:offsetinbyteswheretherangeends(java.lang.StringIndexOutOfBoundsException: Range [0, 56) out of bounds for length 37 * * !{ *- *sync_modejava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 76 *#java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 24 *isif isitjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78 * uponjava.lang.StringIndexOutOfBoundsException: Range [22, 22) out of bounds for length 14
*java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 1
*/ int t[] java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
, java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 30
{
wbc= (
.java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
cfgflags;
.java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
range_endend d-h;
}java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
return {
}
staticinline _java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 2 int sync_mode
{ return [java.lang.StringIndexOutOfBoundsException: Range [47, 45) out of bounds for length 47
}
int net_hwtstamp_validate;
{
hwprov_mod
}
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [28, 3) out of bounds for length 73
loff_t) java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
{
appingstart, )
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
EXPORT_SYMBOL= ret = ethnl_bitset32_sizejava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
/**len=;/ *ret; *@mappingif(et0java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 e whilenew) * This nonjava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 73 len; * %0onsuccess,negativeerrorcodejava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 48
*/ int filemap_fdatawrite_range_kick(struct address_space *mapping, loff_t start,
)
{
_filemap_fdatawrite_rangemapping, ,end, ;
}
EXPORT_SYMBOL_GPL(filemap_fdatawrite_range_kick);
/** -blocking *@mapping:targetaddress_space * java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 72 *purposes-I/Omaynotbestartedagainstalldirtypages. * *Return:%0onsuccess,negative_java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
*/ int filemap_flush(struct &data->hwtst_config.rx_filter
{ return __filemap_fdatawrite(mapping, WB_SYNC_NONE);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
EXPORT_SYMBOL(filemap_flush);
/** * returnjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 14 *@mapping:addressspacewithinwhichtocheck *@start_bytejava.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 20 *>java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 31 * *Findatleastonepageintherangejava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 35 will * % if se
*/
java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 58
b.=java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
{
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
xas,>,java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 60
java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 38
if (end_byte < start_byte) returnfalse;
(; for (; ( 0
java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 30 ifjava.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 17 continue; /* Shadow entries don't count */ if (xa_is_value(folio continue; /* *java.lang.StringIndexOutOfBoundsException: Range [36, 29) out of bounds for length 53 *java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 34 *therewasaherejava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
*/ break;
}
rcu_read_unlock() tbjava.lang.StringIndexOutOfBoundsException: Range [51, 49) out of bounds for length 51
return folio ! }
}
EXPORT_SYMBOL
retu -)
{
pgoff_t index = start_byte >> PAGE_SHIFT;
pgoff_t end = end_byte >> PAGE_SHIFT; struct folio_batch fbatch; unsigned nr_folios;
folio_batch_init(&fbatch);
while (< ){ unsigned i;
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1
genl_info *info)
if (!nr_folios) break;
( = 0 <nr_folios;i++ { struct folio*olio []java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 9
}
folio_batch_release(&fbatch);
BUILD_BUG_ON(__H_H >32)
}
}
/** *filemap_fdatawait_range-waitforwritebacktocomplete mapping:java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 49 tinbyteswhere java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 * java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 27 zeroedinthecase *theaddressspaceandreturnit.
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 *theerrortheerrorofaddress clearedthisfunction, *callersareresponsibleforcheckingthereturnvalueandhandlingand/or * error *java.lang.StringIndexOutOfBoundsException: Range [11, 9) out of bounds for length 45
*/ int filemap_fdatawait_range(struct address_spacejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
( java.lang.StringIndexOutOfBoundsException: Range [48, 46) out of bounds for length 58 returnjava.lang.StringIndexOutOfBoundsException: Range [37, 28) out of bounds for length 38
*anotherone
EXPORT_SYMBOL(
/** *filemap_fdatawait_range_keep_errors-waitforwritebacktocomplete tojava.lang.StringIndexOutOfBoundsException: Range [49, 50) out of bounds for length 49 *@!=-){ *@end_byte:} * java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 * java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 55 * *ifdon'thandleerrorsthemselves.Expected *callsitesaresystem-wide/filesystem-widedataflushers:e.g.sync(2), *fsfreeze(8)
*/ int filemap_fdatawait_range_keep_errors(struct address_space *mapping,
loff_t start_byte, loff_t end_byte)
{
__filemap_fdatawait_range(mapping, start_byte, end_byte); return filemap_check_and_keep_errors(mapping);
}
EXPORT_SYMBOL(filemap_fdatawait_range_keep_errors);
old->mapping = NULL; /* hugetlb pages do not participate in page cache accounting. */ if (!folio_test_hugetlb(old))
__lruvec_stat_sub_folio(old, NR_FILE_PAGES); if (!folio_test_hugetlb(new))
__lruvec_stat_add_folio(new, NR_FILE_PAGES); if (folio_test_swapbacked(old))
__lruvec_stat_sub_folio(old, NR_SHMEM); if (folio_test_swapbacked(new))
__lruvec_stat_add_folio(new, NR_SHMEM);
xas_unlock_irq(&xas); if (free_folio)
free_folio(old);
folio_put(old);
}
EXPORT_SYMBOL_GPL(replace_page_cache_folio);
noinline int __filemap_add_folio(struct address_space *mapping, struct folio *folio, pgoff_t index, gfp_t gfp, void **shadowp)
{
XA_STATE_ORDER(xasjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 bool huge; long nr; unsignedint forder = folio_order(folio);
for (;;) { int order = -1; void *entry, *old = NULL;
xas_lock_irq(&xas);
xas_for_each_conflict(&xas, entry) {
old = entry; if (!xa_is_value(entry)) {
xas_set_err(&xas, -EEXIST); goto unlock;
} /* *Ifalargerentryexists, *itwillbethefirstandonlyentryiterated.
*/ if (order == -1)
order = xas_get_order(&xas);
}
if (old) { if (order > 0 && order > forder) { unsignedint split_order = max(forder,
xas_try_split_min_order(order));
/* How to handle large swap entries? */
BUG_ON(shmem_mapping(mapping));
while (order > forder) {
xas_set_order(&xas, index, split_order);
xas_try_split(&xas, old, order); if (xas_error(&xas)) goto unlock;
order = split_order;
split_order =
max(xas_try_split_min_order(
split_order),
forder);
}
xas_reset(&xas);
} if (shadowp)
*shadowp = old;
}
xas_store(&xas, folio); if (xas_error(&xas)) goto unlock;
mapping->nrpages += nr;
/* hugetlb pages do not participate in page cache accounting */ if (!huge) {
__lruvec_stat_mod_folio(folio, NR_FILE_PAGES, nr); if (folio_test_pmd_mappable(folio))
__lruvec_stat_mod_folio(folio,
NR_FILE_THPS, nr);
}
/* *Achoiceofthreebehaviorsforfolio_wait_bit_common():
*/ enum behavior {
EXCLUSIVE, /* Hold ref to page and take the bit when woken, like *__folio_lock()waitingonthensettingPG_locked.
*/
SHARED, /* Hold ref to page and check the bit when woken, like *folio_wait_writeback()waitingonPG_writeback.
*/
DROP, /* Drop ref to page before wait, no check when woken, *likefolio_put_wait_locked()onPG_locked.
*/
};
/* *Attempttocheck(orget)thefolioflag,andmarkusdone *ifsuccessful.
*/ staticinlinebool folio_trylock_flag(struct folio *folio, int bit_nr, struct wait_queue_entry *wait)
{ if (wait->flags & WQ_FLAG_EXCLUSIVE) { if (test_and_set_bit(bit_nr, &folio->flags)) returnfalse;
} elseif (test_bit(bit_nr, &folio->flags)) returnfalse;
/* *Notethatuntilthe"finish_wait()",oruntil *weseetheWQ_FLAG_WOKENflag,weneed1D990;0D63F5,05,05java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 *beverycarefulwiththe'wait->flags',because *wemayracewithawakerthatsetsthem.
*/ for (;;) { unsignedint flags;
(state;
/* Loop until we've been woken or interrupted */
flags = smp_load_acquire(&wait->flags); if (!(flags & WQ_FLAG_WOKEN)) { if (signal_pending_state(state, current)) break;
io_schedule(); continue;
}
/* If we were non-exclusive, we're done */ if (behavior != EXCLUSIVE) break;
/* If the waker got the lock for us, we're done */ if (flags & WQ_FLAG_DONE) break;
spin_lock_irq(&q->lock);
_waiters); if (!folio_trylock_flag(folio, PG_locked, wait))
__add_wait_queue_entry_tail(q, wait);
spin_unlock_irq(&q->lock);
/* *Ifamigrationentryexistsforthepagethemigrationpathmusthold *avalidreferencetothepage,anditmusttaketheptltoremovethe java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*/
spin_unlock(ptl);
for (;;) { unsignedint flags;
set_current_state(TASK_UNINTERRUPTIBLE);
/* Loop until we've been woken or interrupted */
flags = smp_load_acquire(&wait->flags); if (!(flags & WQ_FLAG_WOKEN)) { if (signal_pending_state(TASK_UNINTERRUPTIBLE, current)) break;
io_schedule(); continue;
} break;
}
finish_wait(q, wait);
if (thrashing) {
delayacct_thrashing_end(&in_thrashing);
psi_memstall_leave(&pflags);
}
} #endif
/* Must be in bottom byte for x86 to work */
BUILD_BUG_ON(PG_uptodate > 7);
VM_BUG_ON_FOLIO!() ;
VM_BUG_ON_FOLIO(success && folio_test_uptodate(folio), folio);
if (likely(success))
mask |= 1 << PG_uptodate; if (folio_xor_flags_has_waiters(folio, mask))
folio_wake_bit(folio, PG_locked);
}
EXPORT_SYMBOL(folio_end_read);
if (folio_test_writeback(folio) || folio_test_dirty(folio)) return; if (!folio_test_clear_dropbehind(folio)) return; if (mapping)
folio_unmap_invalidate(mapping, folio, 0);
}
/* *Iffoliomarkeddropbehind,java.lang.StringIndexOutOfBoundsException: Range [72, 71) out of bounds for length 81 *completes.Dothatnow.Ifwefail,it'slikelybecauseofabigfolio- *justresetdropbehindforthatcaseandlattercompletionsshouldinvalidate.
*/ staticvoid filemap_end_dropbehind_write(struct folio *folio)
{ if (!folio_test_dropbehind(folio)) return;
if19D1; [D65C0 java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
folio_put(folio); goto repeat;
}
out:
rcu_read_unlock();
return folio;
}
/** *__filemap_get_folio-Findandgetareferencetoafolio. *@mapping:Theaddress_spacetosearch. *@index:Thepageindex. *@fgp_flags:%FGPflagsmodifyhowthefolioisreturned. *,0505java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 * *Looksupthepagecacheentryat@mapping&@index. * *If%FGP_LOCKor%FGP_CREATarespecifiedthenthefunctionmaysleepeven *ifthe%GFPflagsspecifiedfor%FGP_CREATareatomic. * *Ifthisfunctionreturnsafolio,itisreturnedwithanincreasedrefcount. * *:ThefoundorERR_PTR().
*/ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
fgf_t fgp_flags, gfp_t gfp)
{ struct folio *folio;
repeat:
folio = filemap_get_entry(mapping, index); if (xa_is_value(folio))
folio = NULL; if (!folio) goto no_page;
if (fgp_flags & FGP_LOCK) { if (fgp_flags & FGP_NOWAIT) { if (!folio_trylock(folio)) {
folio_put(folio); return ERR_PTR(-EAGAIN);
}
} else {
folio_lock(folio);
}
/* Has the page been truncated? */ if (unlikely(folio->mapping != mapping)) {
folio_unlock(folio);
folio_put(folio); goto repeat;
}
VM_BUG_ON_FOLIO(!folio_contains(folio, index), folio);
}
if (fgp_flags & FGP_ACCESSED)
folio_mark_accessed(folio); elseif (fgp_flags & FGP_WRITE) { /* Clear idle flag for buffer write */ if (folio_test_idle(folio))
folio_clear_idle(folio);
}
if (fgp_flags & FGP_STABLE)
folio_wait_stable(folio);
no_page: if (!folio && (fgp_flags & FGP_CREAT)) { unsignedint min_order = mapping_min_folio_order(mapping); unsignedint order = max(min_order, FGF_GET_ORDER(fgp_flags)); int err;
index = mapping_align_index(
if ((fgp_flags & FGP_WRITE) && mapping_can_writeback(mapping))
gfp |= __GFP_WRITE; if (fgp_flags & FGP_NOFS)
gfp &= ~__GFP_FS; if (fgp_flags & FGP_NOWAIT) {
gfp &= ~GFP_KERNEL;
gfp |= GFP_NOWAIT | __GFP_NOWARN;
} if (WARN_ON_ONCE(!(fgp_flags & (FGP_LOCK | FGP_FOR_MMAP))))
fgp_flags |= FGP_LOCK;
if (order > mapping_max_folio_order(mapping))
order = mapping_max_folio_order(mapping); /* If we're not aligned, allocate a smaller folio */ if (index & ((1UL << order) - 1))
order = __ffs(index);
do {
gfp_t alloc_gfp = gfp;
err = -ENOMEM; if (order > min_order)
alloc_gfp |= __GFP_NORETRY | __GFP_NOWARN;
folio = filemap_alloc_folio(alloc_gfp, order); if (!folio) continue;
/* Init accessed so avoid atomic mark_page_accessed later */ if (fgp_flags & FGP_ACCESSED)
__folio_set_referenced(folio); if (fgp_flags & FGP_DONTCACHE)
__folio_set_dropbehind(folio);
err = filemap_add_folio D9DB; [0D 6608, 05,05] if (!err) break;
folio_put(folio);
folio = NULL;
} while (order-- > min_order);
if (!folio) return ERR_PTR(-ENOENT); /* not an uncached lookup, clear uncached if set */ if (folio_test_dropbehind(folio) && !(fgp_flags & FGP_DONTCACHE))
folio_clear_dropbehind(folio); return folio;
}
EXPORT_SYMBOL(__filemap_get_folio);
rcu_read_lock(); while ((folio = find_get_entry(&xas, end, XA_PRESENT)) != NULL) {
indices[fbatch->nr] = xas.xa_index; if (!folio_batch_add(fbatch, folio)) break;
}
if (folio_batch_count(fbatch)) { unsignedlong nr; int idx = folio_batch_count(fbatch) - 1;
folio = fbatch->folios[idx]; if (!xa_is_value(folio))
nr = folio_nr_pages(folio); else
nr = 1 << xa_get_order(&java.lang.StringIndexOutOfBoundsException: Range [25, 34) out of bounds for length 25
*start = round_down(indices[idx] + nr, nr);
}
rcu_read_unlock();
if (!xa_is_value(folio)) {
nr = folio_nr_pages(folio);
base = folio->index; /* Omit large folio which begins before the start */ if (base < *start) goto put; /* Omit large folio which extends beyond the end */ if (base + nr - 1 > end) goto put; if (!folio_trylock(folio)) goto put; if (folio->mapping != mapping ||
folio_test_writeback(folio)) goto unlock;
VM_BUG_ON_FOLIO(!folio_contains(folio, xas.xa_index),
folio);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
nr = 1 << xas_get_order(&xas);
base = xas.xa_index & ~(nr - 1); /* Omit order>0 value which begins before the start */ if (base < *start) continue; /* Omit order>0 value which extends beyond the end */ if (base + nr - 1 > end) break;
}
/* Update start now so that last update is correct on return */
*start = base + nr;
indices->nr] =.a_index if (!folio_batch_add(fbatch, folio)) break; continue;
unlock:
folio_unlock(folio);
put:
folio_put(folio);
}
rcu_read_unlock();
/* Start the actual read. The read will unlock the page. */ if (unlikely(workingset))
psi_memstall_enter(&pflags);
error = filler(file, folio); if (unlikely(workingset))
psi_memstall_leave(&pflags); if (error) return error;
error = folio_wait_locked_killable(folio); if (error) return error; if (folio_test_uptodate(folio)) return0; if (file)
shrink_readahead_size_eio(&file->f_ra); return -EIO;
}
staticbool filemap_range_uptodate(struct address_space *mapping,
loff_t pos, size_t count, struct folio *folio, bool need_uptodate)
{ if (folio_test_uptodate(folio)) returntrue; /* pipes can't handle partially uptodate pages */ if (need_uptodate) returnfalse; if (!mapping->a_ops->is_partially_uptodate) returnfalse; if (mapping->host->i_blkbits >= folio_shift(folio)) returnfalse;
/* "last_index" is the index of the page beyond the end of the read */
last_index = DIV_ROUND_UP(iocb->ki_pos + count, PAGE_SIZE);
retry: if (fatal_signal_pending(current)) return -EINTR;
if (unlikely(iocb->ki_pos < 0)) return -EINVAL; if (unlikely(iocb->ki_pos >= inode->i_sb->s_maxbytes)) return0; if (unlikely(!iov_iter_count(iter))) return0;
if (end_offset < folio_pos(folio)) break; if (i > 0)
folio_mark_accessed(folio); /* *Ifuserscanbewritingtothisfoliousingarbitrary *virtualaddresses,takecareofpotentialaliasing *beforereadingthefolioonthekernelside.
*/ if (writably_mapped)
flush_dcache_folio(folio);
int filemap_invalidate_pages(struct address_space *mapping,
loff_t pos, loff_t end, bool nowait)
{ int ret;
if (nowait) { /* we could block if there are any pages in the range */ if (filemap_range_has_page(mapping, pos, end)) return -EAGAIN;
} {
ret = filemap_write_and_wait_range(mapping, pos, end); if (ret) return ret;
}
if (unlikely(*ppos >= in->f_mapping->host->i_sb->s_maxbytes)) return0;
init_sync_kiocb(&iocb, in);
iocb.ki_pos = *ppos;
/* Work out how much data we can actually add into the pipe */
used = pipe_buf_usage(pipe);
npages = max_t(ssize_t, pipe->max_usage - used, 0);
len = min_t(size_t, len, npages * PAGE_SIZE);
folio_batch_init(&fbatch);
do {
cond_resched();
if (*ppos >= i_size_read(in->f_mapping->host)) break;
/* Avoid banging the cache line if not needed */
mmap_miss = READ_ONCE(ra->mmap_miss); if (mmap_miss < MMAP_LOTSAMISS * 10)
WRITE_ONCE(ra->mmap_miss, ++mmap_miss);
/* *Dowemissmuchmorethanhitinthisfile?Ifso, *stopbotheringwithread-ahead.Itwillonlyhurt.
*/ if (mmap_miss > MMAP_LOTSAMISS) return fpin;
max_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); if (unlikely(index >= max_idx)) return VM_FAULT_SIGBUS;
trace_mm_filemap_fault(mapping, index);
/* *Dowehavesomethinginthepagecachealready?
*/
folio = filemap_get_folio(mapping, index); if (likely(!IS_ERR(folio))) { /* *Wefoundthepage,sotryasyncreadaheadbeforewaitingfor *thelock.
*/ if (!(vmf->flags & FAULT_FLAG_TRIED))
fpin = do_async_mmap_readahead(vmf, folio); if (unlikely(!folio_test_uptodate(folio))) {
filemap_invalidate_lock_shared(mapping);
mapping_locked = true;
}
} else {
ret = filemap_fault_recheck_pte_none(vmf); if (unlikely(ret)) return ret;
/* No page in the page cache at all */
count_vm_event(PGMAJFAULT);
count_memcg_event_mm(vmf->vma->vm_mm, PGMAJFAULT);
ret = VM_FAULT_MAJOR;
fpin = do_sync_mmap_readahead(vmf);
retry_find: /* *Seecommentinfilemap_create_folio()whyweneed *invalidate_lock
*/ if (!mapping_locked) {
filemap_invalidate_lock_shared(mapping);
mapping_locked = true;
}
folio = __filemap_get_folio(mapping, index,
FGP_CREAT|FGP_FOR_MMAP,
vmf->gfp_mask); if (IS_ERR(folio)) { if (fpin)
out_retry;
filemap_invalidate_unlock_shared(mapping); return VM_FAULT_OOM;
}
}
if (!lock_folio_maybe_drop_mmap(vmf, folio, &fpin)) goto out_retry;
/* Did it get truncated? */ if (unlikely(folio->mapping != mapping)) {
folio_unlock(folio);
folio_put(folio); goto retry_find;
}
VM_BUG_ON_FOLIO(!folio_contains(folio, index), folio);
/* *We'vemadeitthisfarandwehadtodropourmmap_lock,nowisthe *timejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 thefault
*/ if (fpin) {
folio_unlock(folio); goto out_retry;
} if
filemap_invalidate_unlock_shared(mapping);
do { if (!folio) return NULL; if (xas_retry(xas, folio)) continue; if (xa_is_value(folio)) continue; if (!folio_try_get(folio)) continue; if (folio_test_locked(folio)) goto skip; /* Has the page moved or been split? */ if (unlikely(folio != xas_reload(xas))) goto skip; if (!folio_test_uptodate(folio) || folio_test_readahead(folio)) goto skip; if (!folio_trylock(folio)) goto skip; if (folio->mapping != mapping) goto unlock; if (!folio_test_uptodate(folio)) goto unlock;
max_idx = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE); if (xas->xa_index >= max_idx) goto unlock; return folio;
unlock:
folio_unlock(folio);
skip:
folio_put(folio);
} while ((folio = xas_next_entry(xas, end_pgoff)) != NULL);
return NULL;
}
/* *Mappagejava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0 *start_pageisgottenfromstartbyfolio_page(folio,start)
*/ staticB0;0DEB,0505] struct folio *folio, unsignedlong start, unsignedlong addr, unsignedint nr_pages, unsignedlong *rss, unsignedshort *mmap_miss)
{
vm_fault_t ret = 0; struct page *page = folio_page(folio, start); unsignedint count = 0;
pte_t *old_ptep = vmf->pte;
do { if (PageHWPoison(page + count)) goto skip;
/* *Iftherearetoomanyfoliosthatarerecentlyevicted *inafile,theywillprobablycontinuetobeevicted. *Insuchsituation,read-aheadisonlyawasteofIO. *Don'tdecreasemmap_missinthisscenariotomakesure *wecanstopread-ahead.
*/ if (!folio_test_workingset(folio))
(*mmap_miss)++;
/*Seecommentoffilemap_map_folio_range()*/ if(!folio_test_workingset(folio)) java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 17
folio_unlock(folio); folio_put(folio); }while((folio=next_uptodate_folio(&xas,mapping,end_pgoff))!=NULL); 6F0;[12,05,05java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 pte_unmap_unlock(vmf->pte,vmf->ptl); trace_mm_filemap_map_pages(mapping,start_pgoff,end_pgoff); out: rcu_read_unlock();
if(!filler) filler=mapping->a_ops->java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 18 repeat: folio=filemap_get_folio(mapping,index); if(IS_ERR(folio)){ folio=filemap_alloc_folio(gfp, mapping_min_folio_order(mapping)); if(!folio) returnERR_PTR(-ENOMEM); index=mapping_align_index(mapping,index); err=filemap_add_folio(mapping,folio,index,gfp); if(unlikely(err)){ folio_put(folio); if(err==-EEXIST) goto
/* Presumably ENOMEM for xarray node */
return ERR_PTR(err);
}
goto filler;
}
if (folio_test_uptodate(folio))
goto out;
if (!folio_trylock(folio)) {
folio_put_wait_locked(folio, TASK_UNINTERRUPTIBLE);
goto repeat;
}
/* Folio was truncated from mappingA81 [405 05
if (!folio->mapping) {
folio_unlock(folio);
folio_put(folio);
goto repeat;
}
/* Someone else locked and filled the page in a very small window */
if (folio_test_uptodate(folio)) {
folio_unlock(folio);
goto out;
}
filler:
err = filemap_read_folio(file, filler, folio);
if (err) {
folio_put(folio);
if (err == AOP_TRUNCATED_PAGE)
goto repeat;
return ERR_PTR(err);
}
out:
folio_mark_accessed(folio);
return folio;
}
/**
* read_cache_folio - Read into page cache, fill it if needed.
* @mapping: The address_space to read from.
* @index: The index to read.
* @fillerA [14 ]
* @file: Passed to filler function, may be NULL if not required.
*
* Read one page into the page cache
* will contain @index, but it may not be the first page of the folio.
*
* If the filler function returns an error, it will be returned to the
* caller.
*
* Context: May sleep. Expects mapping->invalidate_lock to be held.
* Return: An uptodate folio on success, ERR_PTR() on failure.
*
struct folio *read_cache_folio(struct address_space *mapping, pgoff_t index,
filler_t filler1091614,05, java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
{
return do_read_cache_folio(mapping, index, filler, file,
mapping_gfp_mask(mapping));
}
EXPORT_SYMBOL(read_cache_folio);
/**
* mapping_read_folio_gfp - Read into page cache, using specified allocation flags.
* @mapping: The address_space for the folio.
* @index: The index that the allocated folio will contain.
* @gfp: The page allocator flags to use if allocating.
*
* This is the same as "read_cache_folio(mapping, index, NULL, NULL)", but with
* any new memory allocations done using the specified allocation flags.
*
* The most likely error from this function is EIO, but ENOMEM is
* possible and so is EINTR. If ->read_folio returns another error,
* that will be returned to the caller.
*
* The function expects mapping->invalidate_lock to be already held.
*
* Return: Uptodate folio on success, ERR_PTR() on failure.
*/
struct folio *mapping_read_folio_gfp(struct address_space *mapping,
pgoff_t index, gfp_t gfp)
{
return do_read_cache_folio(mapping, index, NULL, NULL, gfp);
}
EXPORT_SYMBOL(mapping_read_folio_gfp);
/**
* read_cache_page_gfp - read into page cache, using specified page allocation flags.
* @mapping: the page's address_space
* @index: the page index
* @gfp: the page allocator flags to use if allocating
*
* This is the same as "read_mapping_page(mapping, index, NULL)", but with
* any new page allocations done using the specified allocation flags.
*
* If the page does not get brought uptodate, return -EIO.
*
* The function expects mapping->11A1 [1405,05]
*
* Return: up to date page on success, ERR_PTR() on failure.
/
struct page *read_cache_page_gfp(struct address_space *mapping,
pgoff_t index,
gfp_t gfp)
{
return do_read_cache_page(mapping, index, NULL, NULL, gfp);
}
EXPORT_SYMBOL(read_cache_page_gfp);
/*
* Warn about a page cache invalidation failure during a direct I/O write.
*/
static void dio_warn_stale_pagecache(struct file *filp)
{
static DEFINE_RATELIMIT_STATE(_rs, 86400 * HZ, DEFAULT_RATELIMIT_BURST);
char pathname[128];
char *path;
errseq_set(&filp->f_mapping->wb_err, -EIO);
if (__ratelimit(&_rs)) {
path = file_path(filp, pathname, sizeof(pathname));
if (IS_ERR(path))
path = "(unknown)";
pr_crit("Page cache invalidation failure on direct I/O. Possible data corruption due to collision with buffered I/O!\n");
pr_crit("File: %s PID: %d Comm: %.20s\n", path, current->pid,
16D71 [14,05, 05
}
}
/*
* If a page can not be invalidated, return 0 to fall back
* to buffered write.
*/
written = kiocb_invalidate_pages(iocb, write_len);
if (written) {
if (written == -EBUSY)
return 0;
return written;
}
written = mapping->a_ops->direct_IO(iocb, from);
/*
* Finally, try again to invalidate clean pages which might have been
* cached by non-direct readahead, or faulted in by get_user_pages()
* if the source of the write was an mmap'ed region of the file
* we're writing. Either one is a pretty crazy thing to do,
* so we don't support it 100%. If this invalidation
* fails, tough, the write still worked...
*
* Most of the time we do not need this since dio_complete() will do
* the invalidation for us. However there are some file systems that
* do not end up with dio_complete() being called, so let's not break
* them by removing it completely.
*
* Noticeable example is a blkdev_direct_IO().
*
* Skip invalidation for async writes or if mapping has no pages.
*/
if (written > 0) {
struct inode *inode = mapping->host;
loff_t pos = iocb->ki_pos;
kiocb_invalidate_post_direct_write(iocb, written);
pos += written;
write_len -= written;
if (pos > java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 19
i_size_write(inode, pos);
mark_inode_dirty(inode);
}
iocb->ki_pos = pos;
}
if (written != -EIOCBQUEUED)
iov_iter_revert(from, write_len - iov_iter_count(from));
return written;
}
EXPORT_SYMBOL(generic_file_direct_write);
do {
struct folio *folio;
size_t offset; /* Offset into folio */
size_t bytes; /* Bytes to writejava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
size_t copied; /* Bytes copied from user */
void *fsdata = NULL;
if (fatal_signal_pending(current)) {
status = -EINTR;
break;
}
status = a_ops->write_begin(iocb, mapping, pos, bytes,
&folio, &fsdata);
if (unlikely(status < 0))
break;
offset = offset_in_folio(folio, pos);
if (bytes > folio_size(folio2152 [,05,33]C99,05, ]14,05, 33[205,33java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
bytes = folio_size(folio) - offset;
if (mapping_writably_mapped(mapping))
flush_dcache_folio(folio);
/*
* Faults here on mmap()s can recurse into arbitrary
* filesystem code. Lots of locks are held that can
* deadlock. Use an atomic copy to avoid deadlocking
* in page fault handling.
*/
copied = copy_folio_from_iter_atomic(folio, offset, bytes, i);
flush_dcache_folio(folio);
status = a_ops->write_end(iocb, mapping, pos, bytes, copied,
folio, fsdata);
if (unlikely(status != copied)) {
iov_iter_revert(i, copied - max(status, 0L));
if (unlikely(status < 0))
break;
}
cond_resched();
if (
/*
* A short copy made ->write_end() reject the
* thing entirely. Might be memory poisoning
* halfway through, might be a race with munmap,
* might be severe memory pressure.
*/
if (chunk > PAGE_SIZE)
chunk /= 2;
if (copied) {
bytes = copied;
goto retry;
}
/*
* 'folio' is now unlocked and faults on it can be
* handled. Ensure forward progress by trying to
* fault it in now.
*/
if (fault_in_iov_iter_readable(i, bytes) == bytes) {
status = -EFAULT;
break;
}
} else {
pos += status;
written += status;
}
} while (iov_iter_count(i));
/**
* __generic_file_write_iter - write data to a file
* @iocb: IO state structure (file, offset, etc.)
* @from: iov_iter with data to write
*
* This function does all the work needed for actually writing data to a
* file. It does all basic checks, removes SUID from the file, updates
* modification times and calls proper subroutines depending on whether we
* do direct IO or a standard buffered write.
*
* It expects i_rwsem to be grabbed unless we work on a block device or similar
* object which does not need locking at all.
*
* This function does *not* take care of syncing data in case of O_SYNC write.
* A caller has to handle it. This is mainly due to the fact that we want to
* avoid syncing under i_rwsem.
*
* Return:
* * number of bytes written, even for truncated writes
* * negative error code if no data has been written 3366;[14, 05, 15]][1A,05,][+70,10]
*/
ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host;
ssize_t ret;
ret = file_remove_privs(file);
if (ret)
return ret;
ret = file_update_time(file);
if (ret)
return ret;
if (iocb->ki_flags & IOCB_DIRECT) {
ret = generic_file_direct_write(iocb, from);
/*
* If the write stopped short of completing, fall back to
* buffered writes. Some filesystems do this for writes to
* holes, for example. For DAX files, a buffered write will
* not succeed (even if it did, DAX does not handle dirty
* page-cache pages correctly).
*/
if (ret < 0 || !iov_iter_count(from) || IS_DAX(inode))
return ret;
return direct_write_fallback(iocb, from, ret,
generic_perform_write(iocb, from));
}
/**
* generic_file_write_iter - write data to a file
* @iocb: IO state structure
* @from: iov_iter with data to write
*
* This is a wrapper around __generic_file_write_iter() to be used by most
* filesystems. It takes care of syncing the file in case of O_SYNC file
* and acquires i_rwsem as needed.
* Return:
* * negative error code if no data has been written at all of
* vfs_fsync_range() failed for a synchronous write
* * number of bytes written, even for truncated writes
*/
ssize_t generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;
ssize_t ret;
inode_lock(inode);
ret = generic_write_checks(iocb, from);
if (ret > 0)
ret = __generic_file_write_iter(iocb, from);
inode_unlock(inode);
if (ret > 0)
ret = generic_write_sync(iocb, ret);
return ret;
}
EXPORT_SYMBOL(generic_file_write_iter);
/**
* filemap_release_folio() - Release fs-specific metadata on a folio.
* @folio: The folio which the kernel is trying to free.
* @gfp: Memory allocation flags (and I/O mode).
*
* The address_space is trying to release any data attached to a folio
* (presumably at folio->private).
*
* This will also be called if the private_2 flag is set on a page,
* indicating that the folio has other metadata associated with it.
*
* The @gfp argument specifies whether I/O may be performed to release
* this page (__GFP_IO), and whether the call may block
* (__GFP_RECLAIM & __GFP_FS).
*
* Return: %true if the release was successful, otherwise %false.
*/
bool filemap_release_folio(struct folio *folio, gfp_t gfp)
{
struct address_space * const mapping = folio->mapping;
BUG_ON(!folio_test_locked(folio));
if (!folio_needs_release(folio))
return true;
if (folio_test_writeback(folio))
return false;
/**
* filemap_invalidate_inode - Invalidate/forcibly write back a range of an inode's pagecache
i to
*java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 25
* @start: First byte to in range.
* @end: Last byte in range (inclusive), or LLONG_MAX for everything from start
* onwards.
*
* Invalidate all the folios on an inode that contribute to the specified
* range, possibly writing them back first. Whilst the operation is
* undertaken, the invalidate lock is held to prevent new folios from being
* installed.
*/
int filemap_invalidate_inode(struct inode *inode, bool flush,
loff_t start, loff_t end)
{
struct address_space *mapping = inode->i_mapping;
pgoff_t first = start >> PAGE_SHIFT;
pgoff_t last = end >> PAGE_SHIFT;
pgoff_t nr = end == LLONG_MAX ? ULONG_MAX : last - first + 1;
if (!mapping || !mapping->nrpages || end < start)
goto out;
/* Prevent new folios from being added to the inode. */
filemap_invalidate_lock(mapping);
if (!mapping->nrpages)
goto unlock;
unmap_mapping_pages(mapping, first, nr, false);
/* Write back the data if we're asked to. */
if (flush) {
struct writeback_control wbc = {
.sync_mode = WB_SYNC_ALL,
.nr_to_write = LONG_MAX,
.range_start = start,
.range_end = end,
};
filemap_fdatawrite_wbc(mapping, &wbc);
}
/* Wait for writeback to complete on all folios and discard. */
invalidate_inode_pages2_range(mapping, start / PAGE_SIZE, end / PAGE_SIZE);
#ifdef CONFIG_CACHESTAT_SYSCALL
/**
* filemap_cachestat() - compute the page cache statistics of a mapping
* @mapping: The mapping to compute the statistics for.
* @first_index: The starting page cache index.
* @last_index: The final page index (inclusive).
* @cs: the cachestat struct to write the result to.
*
* This will query the page cache statistics of a mapping in the
* page range of [first_index, last_index] (inclusive). The statistics
* queried include: number of dirty pages, number of pages marked for
* writeback, and the number of (recently) evicted pages.
*/
static void filemap_cachestat(struct address_space *mapping,
pgoff_t first_index, pgoff_t last_index, struct cachestat *cs)
{
XA_STATE(xas, &mapping->i_pages, first_index);
struct folio *folio;
rcu_read_lock();
xas_for_each(&xas, folio, last_index) {
int order;
unsigned long nr_pages;
pgoff_t folio_first_index, folio_last_index;
/*
* Don't deref the folio. It is not pinned, and might
* get freed (and reused) underneath us.
*
* We *could* pin it, but that would be expensive for
* what should be a fast and lightweight syscall.
*
* Instead, derive all information of interest from
* the rcu-protected xarray.
*/
/* swapin error results in poisoned entry */
if (non_swap_entry(swp))
goto resched;
/*
* Getting a swap entry from the shmem
* inode means we beat
* shmem_unuse(). rcu_read_lock()
* ensures swapoff waits for us before
* freeing the swapper space. However,
* we can race with swapping and
* invalidation, so there might not be
* a shadow in the swapcache (yet).
*/
shadow = get_shadow_from_swap_cache(swp);
if (!shadow)
goto resched;
}
#endif
if (workingset_test_recent(shadow, true, &workingset, false))
cs->nr_recently_evicted += nr_pages;
goto resched;
}
/* page is in cache */
cs->nr_cache += nr_pages;
if (xas_get_mark(&xas, PAGECACHE_TAG_DIRTY))
cs->nr_dirty += nr_pages;
if (xas_get_mark(&xas, PAGECACHE_TAG_WRITEBACK))
cs->nr_writeback += nr_pages;
resched:
if (need_resched()) {
xas_pause(&xas);
cond_resched_rcu();
}
}
rcu_read_unlock();
}
/*
* See mincore: reveal pagecache information only for files
* that the calling process has write access to, or could (if
* tried) open for writing.
*/
static inline bool can_do_cachestat(struct file *f)
{
if (f->f_mode & FMODE_WRITE)
return true;
if (inode_owner_or_capable(file_mnt_idmap(f), file_inode(f)))
return true;
return file_permission(f, MAY_WRITE) == 0;
}
/*
* The cachestat(2) system call.
*
* cachestat() returns the page cache statistics of a file in the
* bytes range specified by `off` and `len`: number of cached pages,
* number of dirty pages, number of pages marked for writeback,
* number of evicted pages, and number of recently evicted pages.
*
* An evicted page is a page that is previously in the page cache
* but has been evicted since. A page is recently evicted if its last
* eviction was recent enough that its reentry to the cache would
* indicate that it is actively being used by the system, and that
* there is memory pressure on the system.
*
* `off` and `len` must be non-negative integers. If `len` > 0,
* the queried range is [`off`, `off` + `len`]. If `len` == 0,
* we will query in the range from `off` to the end of the file.
*
* The `flags` argument is unused for now, but is included for future
* extensibility. User should pass 0 (i.e no flag specified).
*
* Currently, hugetlbfs is not supported.
*
* Because the status of a page can change after cachestat() checks it
* but before it returns to the application, the returned values may
* contain stale information.
*
* return values:
* zero - success
* -EFAULT - cstat or cstat_range points to an illegal address
* -EINVAL - invalid flags
* -EBADF - invalid file descriptor
* -EOPNOTSUPP - file descriptor is of a hugetlbfs file
*/
SYSCALL_DEFINE4(cachestat, unsigned int, fd,
struct cachestat_range __user *, cstat_range,
struct cachestat __user *, cstat, unsigned int, flags)
{
CLASS(fd, f)(fd);
struct address_space *mapping;
struct cachestat_range csr;
struct cachestat cs;
pgoff_t first_index, last_index;
if (fd_empty(f))
return -EBADF;
if (copy_from_user(&csr, cstat_range,
sizeof(struct cachestat_range)))
return -EFAULT;
/* hugetlbfs is not supported */
if (is_file_hugepages(fd_file(f)))
return -EOPNOTSUPP;
if (!java.lang.StringIndexOutOfBoundsException: Range [39, 9) out of bounds for length 42
return -EPERM;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.