Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'bcachefs-2024-01-26' of https://evilpiepirate.org/git/bcachefs

Pull bcachefs fixes from Kent Overstreet:

- fix for REQ_OP_FLUSH usage; this fixes filesystems going read only
with -EOPNOTSUPP from the block layer.

(this really should have gone in with the block layer patch causing
the -EOPNOTSUPP, or should have gone in before).

- fix an allocation in non-sleepable context

- fix one source of srcu lock latency, on devices with terrible discard
latency

- fix a reattach_inode() issue in fsck

* tag 'bcachefs-2024-01-26' of https://evilpiepirate.org/git/bcachefs:
bcachefs: __lookup_dirent() works in snapshot, not subvol
bcachefs: discard path uses unlock_long()
bcachefs: fix incorrect usage of REQ_OP_FLUSH
bcachefs: Add gfp flags param to bch2_prt_task_backtrace()

+42 -32
+1 -1
fs/bcachefs/alloc_background.c
··· 1715 1715 * This works without any other locks because this is the only 1716 1716 * thread that removes items from the need_discard tree 1717 1717 */ 1718 - bch2_trans_unlock(trans); 1718 + bch2_trans_unlock_long(trans); 1719 1719 blkdev_issue_discard(ca->disk_sb.bdev, 1720 1720 k.k->p.offset * ca->mi.bucket_size, 1721 1721 ca->mi.bucket_size,
+2 -2
fs/bcachefs/btree_locking.c
··· 92 92 continue; 93 93 94 94 bch2_btree_trans_to_text(out, i->trans); 95 - bch2_prt_task_backtrace(out, task, i == g->g ? 5 : 1); 95 + bch2_prt_task_backtrace(out, task, i == g->g ? 5 : 1, GFP_NOWAIT); 96 96 } 97 97 } 98 98 ··· 227 227 prt_printf(&buf, "backtrace:"); 228 228 prt_newline(&buf); 229 229 printbuf_indent_add(&buf, 2); 230 - bch2_prt_task_backtrace(&buf, trans->locking_wait.task, 2); 230 + bch2_prt_task_backtrace(&buf, trans->locking_wait.task, 2, GFP_NOWAIT); 231 231 printbuf_indent_sub(&buf, 2); 232 232 prt_newline(&buf); 233 233 }
+1 -1
fs/bcachefs/debug.c
··· 627 627 prt_printf(&i->buf, "backtrace:"); 628 628 prt_newline(&i->buf); 629 629 printbuf_indent_add(&i->buf, 2); 630 - bch2_prt_task_backtrace(&i->buf, task, 0); 630 + bch2_prt_task_backtrace(&i->buf, task, 0, GFP_KERNEL); 631 631 printbuf_indent_sub(&i->buf, 2); 632 632 prt_newline(&i->buf); 633 633
+1 -1
fs/bcachefs/fs-io.c
··· 79 79 continue; 80 80 81 81 bio = container_of(bio_alloc_bioset(ca->disk_sb.bdev, 0, 82 - REQ_OP_FLUSH, 82 + REQ_OP_WRITE|REQ_PREFLUSH, 83 83 GFP_KERNEL, 84 84 &c->nocow_flush_bioset), 85 85 struct nocow_flush, bio);
+12 -11
fs/bcachefs/fsck.c
··· 119 119 if (!ret) 120 120 *snapshot = iter.pos.snapshot; 121 121 err: 122 - bch_err_msg(trans->c, ret, "fetching inode %llu:%u", inode_nr, *snapshot); 123 122 bch2_trans_iter_exit(trans, &iter); 124 123 return ret; 125 124 } 126 125 127 - static int __lookup_dirent(struct btree_trans *trans, 126 + static int lookup_dirent_in_snapshot(struct btree_trans *trans, 128 127 struct bch_hash_info hash_info, 129 128 subvol_inum dir, struct qstr *name, 130 - u64 *target, unsigned *type) 129 + u64 *target, unsigned *type, u32 snapshot) 131 130 { 132 131 struct btree_iter iter; 133 132 struct bkey_s_c_dirent d; 134 - int ret; 135 - 136 - ret = bch2_hash_lookup(trans, &iter, bch2_dirent_hash_desc, 137 - &hash_info, dir, name, 0); 133 + int ret = bch2_hash_lookup_in_snapshot(trans, &iter, bch2_dirent_hash_desc, 134 + &hash_info, dir, name, 0, snapshot); 138 135 if (ret) 139 136 return ret; 140 137 ··· 222 225 223 226 struct bch_inode_unpacked root_inode; 224 227 struct bch_hash_info root_hash_info; 225 - ret = lookup_inode(trans, root_inum.inum, &root_inode, &snapshot); 228 + u32 root_inode_snapshot = snapshot; 229 + ret = lookup_inode(trans, root_inum.inum, &root_inode, &root_inode_snapshot); 226 230 bch_err_msg(c, ret, "looking up root inode"); 227 231 if (ret) 228 232 return ret; 229 233 230 234 root_hash_info = bch2_hash_info_init(c, &root_inode); 231 235 232 - ret = __lookup_dirent(trans, root_hash_info, root_inum, 233 - &lostfound_str, &inum, &d_type); 236 + ret = lookup_dirent_in_snapshot(trans, root_hash_info, root_inum, 237 + &lostfound_str, &inum, &d_type, snapshot); 234 238 if (bch2_err_matches(ret, ENOENT)) 235 239 goto create_lostfound; 236 240 ··· 248 250 * The bch2_check_dirents pass has already run, dangling dirents 249 251 * shouldn't exist here: 250 252 */ 251 - return lookup_inode(trans, inum, lostfound, &snapshot); 253 + ret = lookup_inode(trans, inum, lostfound, &snapshot); 254 + bch_err_msg(c, ret, "looking up lost+found %llu:%u in (root inode %llu, snapshot root %u)", 255 + inum, snapshot, root_inum.inum, bch2_snapshot_root(c, snapshot)); 256 + return ret; 252 257 253 258 create_lostfound: 254 259 /*
+1 -1
fs/bcachefs/journal.c
··· 233 233 prt_str(&pbuf, "entry size: "); 234 234 prt_human_readable_u64(&pbuf, vstruct_bytes(buf->data)); 235 235 prt_newline(&pbuf); 236 - bch2_prt_task_backtrace(&pbuf, current, 1); 236 + bch2_prt_task_backtrace(&pbuf, current, 1, GFP_NOWAIT); 237 237 trace_journal_entry_close(c, pbuf.buf); 238 238 printbuf_exit(&pbuf); 239 239 }
+2 -1
fs/bcachefs/journal_io.c
··· 1988 1988 percpu_ref_get(&ca->io_ref); 1989 1989 1990 1990 bio = ca->journal.bio; 1991 - bio_reset(bio, ca->disk_sb.bdev, REQ_OP_FLUSH); 1991 + bio_reset(bio, ca->disk_sb.bdev, 1992 + REQ_OP_WRITE|REQ_PREFLUSH); 1992 1993 bio->bi_end_io = journal_write_endio; 1993 1994 bio->bi_private = ca; 1994 1995 closure_bio_submit(bio, cl);
+15 -7
fs/bcachefs/str_hash.h
··· 160 160 } 161 161 162 162 static __always_inline int 163 - bch2_hash_lookup(struct btree_trans *trans, 163 + bch2_hash_lookup_in_snapshot(struct btree_trans *trans, 164 164 struct btree_iter *iter, 165 165 const struct bch_hash_desc desc, 166 166 const struct bch_hash_info *info, 167 167 subvol_inum inum, const void *key, 168 - unsigned flags) 168 + unsigned flags, u32 snapshot) 169 169 { 170 170 struct bkey_s_c k; 171 - u32 snapshot; 172 171 int ret; 173 - 174 - ret = bch2_subvolume_get_snapshot(trans, inum.subvol, &snapshot); 175 - if (ret) 176 - return ret; 177 172 178 173 for_each_btree_key_upto_norestart(trans, *iter, desc.btree_id, 179 174 SPOS(inum.inum, desc.hash_key(info, key), snapshot), ··· 187 192 bch2_trans_iter_exit(trans, iter); 188 193 189 194 return ret ?: -BCH_ERR_ENOENT_str_hash_lookup; 195 + } 196 + 197 + static __always_inline int 198 + bch2_hash_lookup(struct btree_trans *trans, 199 + struct btree_iter *iter, 200 + const struct bch_hash_desc desc, 201 + const struct bch_hash_info *info, 202 + subvol_inum inum, const void *key, 203 + unsigned flags) 204 + { 205 + u32 snapshot; 206 + return bch2_subvolume_get_snapshot(trans, inum.subvol, &snapshot) ?: 207 + bch2_hash_lookup_in_snapshot(trans, iter, desc, info, inum, key, flags, snapshot); 190 208 } 191 209 192 210 static __always_inline int
+5 -5
fs/bcachefs/util.c
··· 272 272 console_unlock(); 273 273 } 274 274 275 - int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *task, unsigned skipnr) 275 + int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *task, unsigned skipnr, 276 + gfp_t gfp) 276 277 { 277 278 #ifdef CONFIG_STACKTRACE 278 279 unsigned nr_entries = 0; 279 - int ret = 0; 280 280 281 281 stack->nr = 0; 282 - ret = darray_make_room(stack, 32); 282 + int ret = darray_make_room_gfp(stack, 32, gfp); 283 283 if (ret) 284 284 return ret; 285 285 ··· 308 308 } 309 309 } 310 310 311 - int bch2_prt_task_backtrace(struct printbuf *out, struct task_struct *task, unsigned skipnr) 311 + int bch2_prt_task_backtrace(struct printbuf *out, struct task_struct *task, unsigned skipnr, gfp_t gfp) 312 312 { 313 313 bch_stacktrace stack = { 0 }; 314 - int ret = bch2_save_backtrace(&stack, task, skipnr + 1); 314 + int ret = bch2_save_backtrace(&stack, task, skipnr + 1, gfp); 315 315 316 316 bch2_prt_backtrace(out, &stack); 317 317 darray_exit(&stack);
+2 -2
fs/bcachefs/util.h
··· 348 348 void bch2_print_string_as_lines(const char *prefix, const char *lines); 349 349 350 350 typedef DARRAY(unsigned long) bch_stacktrace; 351 - int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *, unsigned); 351 + int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *, unsigned, gfp_t); 352 352 void bch2_prt_backtrace(struct printbuf *, bch_stacktrace *); 353 - int bch2_prt_task_backtrace(struct printbuf *, struct task_struct *, unsigned); 353 + int bch2_prt_task_backtrace(struct printbuf *, struct task_struct *, unsigned, gfp_t); 354 354 355 355 static inline void prt_bdevname(struct printbuf *out, struct block_device *bdev) 356 356 {