MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bnoreuselist

Function bnoreuselist

freebsd/kern/vfs_subr.c:2155–2197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2153}
2154
2155int
2156bnoreuselist(struct bufv *bufv, struct bufobj *bo, daddr_t startn, daddr_t endn)
2157{
2158 struct buf *bp;
2159 int error;
2160 daddr_t lblkno;
2161
2162 ASSERT_BO_LOCKED(bo);
2163
2164 for (lblkno = startn;;) {
2165again:
2166 bp = BUF_PCTRIE_LOOKUP_GE(&bufv->bv_root, lblkno);
2167 if (bp == NULL || bp->b_lblkno >= endn ||
2168 bp->b_lblkno < startn)
2169 break;
2170 error = BUF_TIMELOCK(bp, LK_EXCLUSIVE | LK_SLEEPFAIL |
2171 LK_INTERLOCK, BO_LOCKPTR(bo), "brlsfl", 0, 0);
2172 if (error != 0) {
2173 BO_RLOCK(bo);
2174 if (error == ENOLCK)
2175 goto again;
2176 return (error);
2177 }
2178 KASSERT(bp->b_bufobj == bo,
2179 ("bp %p wrong b_bufobj %p should be %p",
2180 bp, bp->b_bufobj, bo));
2181 lblkno = bp->b_lblkno + 1;
2182 if ((bp->b_flags & B_MANAGED) == 0)
2183 bremfree(bp);
2184 bp->b_flags |= B_RELBUF;
2185 /*
2186 * In the VMIO case, use the B_NOREUSE flag to hint that the
2187 * pages backing each buffer in the range are unlikely to be
2188 * reused. Dirty buffers will have the hint applied once
2189 * they've been written.
2190 */
2191 if ((bp->b_flags & B_VMIO) != 0)
2192 bp->b_flags |= B_NOREUSE;
2193 brelse(bp);
2194 BO_RLOCK(bo);
2195 }
2196 return (0);
2197}
2198
2199/*
2200 * Truncate a file's buffer and pages to a specified length. This

Callers 1

vop_stdadviseFunction · 0.85

Calls 2

bremfreeFunction · 0.85
brelseFunction · 0.85

Tested by

no test coverage detected