inode.c (0be5b38bce6c4d3563f7575f6bac94806b2fbc17) inode.c (69c8e6ce022fd87abb9c8dbbdcfd312d6513b055)
1// SPDX-License-Identifier: GPL-2.0
2
3#include "bcachefs.h"
4#include "btree_key_cache.h"
5#include "btree_write_buffer.h"
6#include "bkey_methods.h"
7#include "btree_update.h"
8#include "buckets.h"

--- 370 unchanged lines hidden (view full) ---

379 if (IS_ERR(inode_p))
380 return PTR_ERR(inode_p);
381
382 bch2_inode_pack_inlined(inode_p, inode);
383 inode_p->inode.k.p.snapshot = iter->snapshot;
384 return bch2_trans_update(trans, iter, &inode_p->inode.k_i, flags);
385}
386
1// SPDX-License-Identifier: GPL-2.0
2
3#include "bcachefs.h"
4#include "btree_key_cache.h"
5#include "btree_write_buffer.h"
6#include "bkey_methods.h"
7#include "btree_update.h"
8#include "buckets.h"

--- 370 unchanged lines hidden (view full) ---

379 if (IS_ERR(inode_p))
380 return PTR_ERR(inode_p);
381
382 bch2_inode_pack_inlined(inode_p, inode);
383 inode_p->inode.k.p.snapshot = iter->snapshot;
384 return bch2_trans_update(trans, iter, &inode_p->inode.k_i, flags);
385}
386
387int __bch2_fsck_write_inode(struct btree_trans *trans,
388 struct bch_inode_unpacked *inode,
389 u32 snapshot)
390{
391 struct bkey_inode_buf *inode_p =
392 bch2_trans_kmalloc(trans, sizeof(*inode_p));
393
394 if (IS_ERR(inode_p))
395 return PTR_ERR(inode_p);
396
397 bch2_inode_pack(inode_p, inode);
398 inode_p->inode.k.p.snapshot = snapshot;
399
400 return bch2_btree_insert_nonextent(trans, BTREE_ID_inodes,
401 &inode_p->inode.k_i,
402 BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
403}
404
405int bch2_fsck_write_inode(struct btree_trans *trans,
406 struct bch_inode_unpacked *inode,
407 u32 snapshot)
408{
409 int ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
410 __bch2_fsck_write_inode(trans, inode, snapshot));
411 bch_err_fn(trans->c, ret);
412 return ret;
413}
414
387struct bkey_i *bch2_inode_to_v3(struct btree_trans *trans, struct bkey_i *k)
388{
389 struct bch_inode_unpacked u;
390 struct bkey_inode_buf *inode_p;
391 int ret;
392
393 if (!bkey_is_inode(&k->k))
394 return ERR_PTR(-ENOENT);

--- 802 unchanged lines hidden ---
415struct bkey_i *bch2_inode_to_v3(struct btree_trans *trans, struct bkey_i *k)
416{
417 struct bch_inode_unpacked u;
418 struct bkey_inode_buf *inode_p;
419 int ret;
420
421 if (!bkey_is_inode(&k->k))
422 return ERR_PTR(-ENOENT);

--- 802 unchanged lines hidden ---