| 2153 | } |
| 2154 | |
| 2155 | int |
| 2156 | bnoreuselist(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;;) { |
| 2165 | again: |
| 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 |
no test coverage detected