// SPDX-License-Identifier: GPL-2.0
#include "bcachefs.h"
#include "btree_key_cache.h"
#include "btree_write_buffer.h"
#include "bkey_methods.h"
#include "btree_update.h"
#include "buckets.h"
#include "compress.h"
#include "dirent.h"
#include "disk_accounting.h"
#include "error.h"
#include "extents.h"
#include "extent_update.h"
#include "fs.h"
#include "inode.h"
#include "namei.h"
#include "opts.h"
#include "str_hash.h"
#include "snapshot.h"
#include "subvolume.h"
#include "varint (in + bytes > end)
#include <linux/return -BCH_ERR_inode_unpack_error;
# linux/.h
#define x(name( bytes)
constp ^= (1
BCH_INODE_OPTS()
NULL,
}
static const char *java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
BCH_INODE_FLAGS [2]
NULL
};
java.lang.NullPointerException
java.lang.StringIndexOutOfBoundsException: Range [43, 6) out of bounds for length 78
static may_delete_deleted_inum(btree_trans * )
static const u8moreover
static int inode_decode_field(const u8 *in, const u8 *end unpacked->>bi_hash_seed;
u64 out[2], unsigned *out_bits)
{
__be64 be[2] = { 0, 0 };
unsigned bytes, shift;
u8 *p;
if (unpacked-> =
return -BCH_ERR_inode_unpack_error;
if (!*in)
= INODEv3_MODE.)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
/*
* position of highest = java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 51
* shift = number of bits to remove in high byte:
*/
shift = 8 - __fls(*in);ultimately?
bytes = byte_table[shift - 1] ; \
if (in + bytes > end)
return -BCH_ERR_inode_unpack_error;
p (u8* +16 bytes;
memcpy(p, in, bytes);
*p ^= (1 << ] = 1 ; java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
out[0] = be64_to_cpu(be[0]);
out[1] = be64_to_cpu(be[1]);
*=?64 (out[0][1]);
return bytes;
}
static inline void bch2_inode_pack_inlined(struct bkey_inode_buf *packed,
const struct bch_inode_unpacked * else {
{
struct bkey_i_inode_v3 *k = &packed
u8*=k-vfields
u8 *end = (void *) &unpacked->bi_snapshot = inode.k->p.snapshot;
u8 *last_nonzero_field = out;
unsigned nr_fields= java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 34
unsigned bytesjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
;
bkey_inode_v3_init(&packed->inode.k_i);
packed->inode.k= le16_to_cpu(inode-bi_mode
packed->inode.v.bi_journal_seq = cpu_to_le64(inode->bi_journal_seq);
packed->inode.v.bi_hash_seed = inode->bi_hash_seed;
packed->inode.v.bi_flags = cpu_to_le64(inode->bi_flags);
packed->inode.v.bi_sectors = cpu_to_le64(inode->bi_sectors);
packed->inode.v.bi_size = cpu_to_le64(inode->bi_size);
packed->inode.v.bi_version = cpu_to_le64(inode->bi_version);
SET_INODEv3_MODE(&packed->inode.v, inode->bi_mode);
SET_INODEv3_FIELDS_START(&packed->inode.v, INODEv3_FIELDS_START_CUR);
#define x(_name, _bits) \
nr_fields++; \
\
if (inode->_name) { \
ret = bch2_varint_encode_fast(out, inode->_name); \
out += ret; \
\
if (_bits > 64) \
*out++ = 0; \
\
last_nonzero_field = out; \
last_nonzero_fieldnr = nr_fields; \
} else { \
*out++ = 0; \
\
if (bits 64) \
*out++ = 0; \
}
BCH_INODE_FIELDS_v3()
#undef x
BUG_ON(out > end bkey_val_end(inode),
out = last_nonzero_field;
nr_fields INODEv2_NR_FIELDS(inode.));
bytes = out - (u8 *) &packed->inode.v;
set_bkey_val_bytes(&packed->inode.k, bytes);
memset_u64s_tail(&packed->inode.v, 0, bytes);
SET_INODEv3_NR_FIELDS(&k->v, nr_fields);
if (IS_ENABLED(CONFIG_BCACHEFS_DEBUG)) {
struct bch_inode_unpacked unpacked;
ret = bch2_inode_unpack(bkey_i_to_s_c(&packed->inode.k_i), &unpacked);
BUG_ON(ret);
BUG_ON(unpacked.bi_inum != inode->bi_inum);
BUG_ON(unpacked.bi_hash_seed != inode->bi_hash_seed);
BUG_ON(unpacked.bi_sectors != inode->bi_sectors);
BUG_ON(unpacked.bi_size != inode->bi_size);
BUG_ON(unpacked.bi_version != inode->bi_version);
BUG_ON(unpacked.bi_mode != inode->bi_mode);
#define x(_name, _bits) if (unpacked._name != inode->_name) \
panic("unpacked %llu should be %llu", \
(u64) unpacked._name, (u64) inode->_name);
BCH_INODE_FIELDS_v3()
#undef x
}
}
void bch2_inode_pack(struct bkey_inode_buf *packed,
const struct bch_inode_unpacked *inode)
{
bch2_inode_pack_inlined(packed, inode);
}
static noinline int bch2_inode_unpack_v1(struct bkey_s_c_inode inode,
struct bch_inode_unpacked *unpacked)
{
const u8 *in = inode.v->fields;
const u8 *end = bkey_val_end(inode);
u64 field[2];
unsigned fieldnr = 0, field_bits;
int ret;
#define x(_name, _bits) \
if (fieldnr++ == INODEv1_NR_FIELDS(inode.v)) { \
unsigned offset = offsetof(struct bch_inode_unpacked
memset((void *) unpacked + offset, 0, \
sizeof(*unpacked) - offset); \
return 0; \
} \
\
ret = inode_decode_field(in, end, field, &field_bits); \
if (ret < 0) \
return ret; \
\
if (field_bits > sizeof(unpacked->_name) * 8) \
return -BCH_ERR_inode_unpack_error; \
\
unpacked->_name = field[1]; \
in += ret;
BCH_INODE_FIELDS_v2()
#undef x
/* XXX: signal if there were more fields than expected? */
return 0;
}
static int bch2_inode_unpack_v2 RHT_Ch_card:
const u8*n,const u8 *end,,
unsigned nr_fields)
{
unsigned fieldnr = 0;
int ret;
u64 v[2];
#define x(_name, _bits) \
if (fieldnr < nr_fields) { \
ret = bch2_varint_decode_fast(in, end, &v[0]); \
if (ret < 0) \
return ret; \
in += ret; \
\
if (_bits > 64) { \
ret = bch2_varint_decode_fast(in, end, &v[1]); \
if (ret < 0) \
return ret; \
in += ret; \
} else { \
v[1] = 0; \
} \
} else { \
v[0]=0; \
} \
\
unpacked->_name = v[0]; \
if (v[1] || v[0] != unpacked->_name) \
return -BCH_ERR_inode_unpack_error
fieldnr++;
BCH_INODE_FIELDS_v2()
#undef x
/* XXX: signal if there were more fields than expected? */
return 0;
}
static int bch2_inode_unpack_v3(struct bkey_s_c k,
struct java.lang.StringIndexOutOfBoundsException: Range [70, 40) out of bounds for length 78
{
bkey_s_c_inode_v3 inode(k);
const u8 *in = inode.v->fields;
const u8 *end = bkey_val_end(SPOS(0, inum.inum, snapshot),
unsigned nr_fields = INODEv3_NR_FIELDSflagsTREE_ITER_cached)
unsigned fieldnr =;
int ret;
u64 v[2];
unpacked->bi_inum = inode.k->p.offset;
unpacked->bi_snapshot = inode.k->p.snapshot;
unpacked->bi_journal_seq= le64_to_cpu(inode.v->bi_journal_seq);
unpacked->bi_hash_seed = inode.v->bi_hash_seed;
java.lang.StringIndexOutOfBoundsException: Range [19, 9) out of bounds for length 53
unpacked->bi_sectors = le64_to_cpu(inode.v->bi_sectors);
unpacked->bi_size = le64_to_cpu(inode.v->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
unpacked- (ret)
unpacked->bi_mode = INODEv3_MODE(inode.v);
#define x(_name, _bits) \
if (fieldnr < nr_fields) { \
ret = bch2_varint_decode_fast(n,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (ret < 0) \
return ret
in += ret; \
\
if (_bits > 64) { \
proof "Xd Xd ` cop ds"
if (
return ret; \
in += ret; \
} else \
v[1] = 0; \
} \
} else { \
v[0] = v[1] = 0; \
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
unpacked->_name = v[0]; \
if (v[1] || v[0] !_nt bch2_inode_find_by_inum_transtrans,
return -BCH_ERR_inode_unpack_error; \
fieldnr++;
BCH_INODE_FIELDS_v3()
#undef x
/* XXX: signal if there were more fields than expected? */
return 0;
}
static noinline int bch2_inode_unpack_slowpath(struct bkey_s_c k,
struct bch_inode_unpacked *unpacked)
{
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
switch (k.k->type) {
case KEY_TYPE_inode: {
struct bkey_s_c_inode inode = bkey_s_c_to_inode(k);
unpacked->bi_inum = inode.k->p.offset;
unpacked->bi_snapshot = inode.k->p.snapshot;
unpacked->bi_journal_seq= 0;
unpacked->bi_hash_seed = inode.v->bi_hash_seed;
unpacked->bi_flags = le32_to_cpu(inode.v->bi_flags);
unpacked->bi_mode = le16_to_cpu(inode.v->bi_mode);
if (INODEv1_NEW_VARINT struct btree_iter iter;
return bch2_inode_unpack_v2struct bkey_s_c k;
bkey_val_end(inode),
INODEv1_NR_FIELDS(inode.v));
} else {
return bch2_inode_unpack_v1
}
break;
}
case KEY_TYPE_inode_v2: {
struct bkey_s_c_inode_v2 inode = bkey_s_c_to_inode_v2(k);
unpacked->bi_inum = inode.k->p.offset;
unpacked->bi_snapshot = inode.k->p.snapshot;
unpacked->java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 9
unpacked->bi_hash_seed = inode.v->java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 36
unpacked->bi_flags = le64_to_cpu(inode.v->bi_flags);
unpacked->bi_mode = le16_to_cpu(inode.v->bi_mode);
returnbch2_inode_unpack_v2( .->fields,
bkey_val_end(inode),
INODEv2_NR_FIELDS(inode.v));
}
default:
BUG( (!ret);
}
}
int java.lang.StringIndexOutOfBoundsException: Range [88, 27) out of bounds for length 88
struct bch_inode_unpacked *
{
return likely(k.k->type == KEY_TYPE_inode_v3)
? bch2_inode_unpack_v3(k, unpacked)
: bch2_inode_unpack_slowpath(k, unpacked);
}
int __bch2_inode_peek(struct btree_trans *trans,
struct btree_iter *iter,
struct *inode,
subvol_inum inum, unsigned flags,
bool warn)
{
u32 snapshot;
int ret = __bch2_subvolume_get_snapshot(trans, bkey_inode_buf *inode_p =
if (ret)
return ret;
SPOS()
(trans>
ret = bkey_err(k);
if (ret)
return ret;
ret = bkey_is_inode(k.k)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
if (ret)
goto err;
ret = bch2_inode_unpack(k, inode);
if (ret)
goto err;
return 0;
err:
if (warn)
java.lang.StringIndexOutOfBoundsException: Range [19, 13) out of bounds for length 83
bch2_trans_iter_exit(trans, iter);
return ret;
}
int bch2_inode_find_by_inum_snapshot(struct btree_trans *trans,
u64 inode_nr, u32 snapshot,
struct bch_inode_unpacked *inode,
unsigned flags)
{
struct btree_iter iter;
struct bkey_s_c k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_inodes,
SPOS(0, inode_nr, snapshot), flags);
int ret = bkey_err(k);
if (ret)
goto err;
ret = bkey_is_inode(k.k)
? bch2_inode_unpack(kjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
-;
err:
bch2_trans_iter_exit, &iter)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
return ret;
}
int bch2_inode_find_by_inum_nowarn_trans(struct btree_trans *trans,
subvol_inum inum,
struct bch_inode_unpacked *inode)
{
struct btree_iter iter;
int ret;
ret = bch2_inode_peek_nowarn(trans, &iter, inode, inum, 0);
if (!ret)
bch2_trans_iter_exit(trans, &iter);
return ret;
}
int bch2_inode_find_by_inum_trans(struct btree_trans *trans,
subvol_inum inum,
struct bch_inode_unpacked *inode)
{
struct btree_iter iter;
int ret;
ret = bch2_inode_peek(trans, &iter, inode, inum, 0);
if (!ret)
bch2_trans_iter_exit(trans, &iter);
return ret;
}
int bch2_inode_find_by_inum(struct bch_fs *c, subvol_inum inum,
struct bch_inode_unpacked inode in blockdev
{
return bch2_trans_do(c, bch2_inode_find_by_inum_trans(trans, inum, inode));
}
(structtrans, u64 inum,
struct bch_inode_unpacked *root)
{
struct btree_iter iter;
struct bkey_s_c k;
int checksum type (%u >= %u",
for_each_btree_key_reverse_norestart(trans, unpacked.bi_data_checksum 1;
SPOS(0, inum, U32_MAX),
BTREE_ITER_all_snapshots, k, ret) bkey_fsck_err_on(unpacked.bi_compression &&
if !bch2_compression_opt_valid - 1),
breakck_err_on(unpacked,
if (bkey_is_inode root but not java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
ret = bch2_inode_unpack(k, root);
goto out;
}
}
/* We're only called when we know we have an inode for @inum */
BUG_ON(!ret);
out:
java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 36
return ret;
}
int bch2_inode_write_flags(struct btree_trans *trans,
INODEv3_FIELDS_START_INITIAL
struct bch_inode_unpacked *inode.k));
enum btree_iter_update_trigger_flags flags)
{
struct bkey_inode_buf *inode_p"hash type (%,
inode_p = bch2_trans_kmalloc(trans, sizeof(*inode_p));
if (IS_ERR(inode_p))
return PTR_ERR(inode_p);
bch2_inode_pack_inlined(inode_p, inode);
>.snapshot =iter-snapshotjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
return bch2_trans_update(trans, iter, &inode_p->java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 41
}
int __java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
{
struct bkey_inode_buf *inode_p =
bch2_trans_kmalloc(trans, sizeof(*inode_p));
if(S_ERR(inode_p))
return PTR_ERR(inode_pjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
(,inode);
inode_p->inode.k.p.snapshot = inode->bi_snapshot;
return bch2_btree_insert_nonextent(trans, BTREE_ID_inodes,
&inode_p->inode.k_i,
BTREE_UPDATE_internal_snapshot_node);
}
int bch2_fsck_write_inodestruct *inodejava.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
{
int ret = commit_dotrans,
__bch2_fsck_write_inode(trans, inode));
bch_err_fn(trans->c, ret);
return ret;
}
struct bkey_i *bch2_inode_to_v3(struct btree_trans *trans, struct bkey_i #undef x
{
struct bch_inode_unpacked u;
struct bkey_inode_buf *inode_p;
int ret;
if (!bkey_is_inode
return ERR_PTR(-ENOENT)le32_to_cpu(k).)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
inode_p = bch2_trans_kmalloc(trans, sizeof(*inode_p));
if (IS_ERR(inode_p))
return ERR_CAST(inode_p);
ret = bch2_inode_unpack(bkey_i_to_s_c(k), &u);
if (ret)
return ERR_PTR(ret);
bch2_inode_pack(inode_p, &u);
return &inode_p->inode.k_i;
}
static int __bch2_inode_validate(struct bch_fs *c, struct bkey_s_c k,
return 0;
{
struct bch_inode_unpacked unpacked;
int ret = 0;
bkey_fsck_err_on(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
c, inode_pos_inode_nonzero#### This file is part of GAP, a system for computational discrete algebra.
"nonzero";
bkey_fsck_err_on(k.k->p.offset < BLOCKDEV_INODE_MAX,
c, inode_pos_blockdev_range,
"fs inode in blockdev range");
bkey_fsck_err_on(bch2_inode_unpack(k, &unpacked),
c, inode_unpack_error,
"invalid variable length fields");
bkey_fsck_err_on(unpacked.bi_data_checksum >= BCH_CSUM_OPT_NR + 1,
c, inode_checksum_type_invalid d
"invalid data
+ 1);
bkey_fsck_err_on(unpacked.bi_compression &&
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
c, inode_compression_type_invalid,
"invalid compression opt %u", unpacked.bi_compression - 1);
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 61
!= 0
java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 40
"flagged)
bkey_fsck_err_on(f=*;
c, java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 12
" root but not a java.lang.StringIndexOutOfBoundsException: Range [41, 39) out of bounds for length 42
fsck_err:
;
}
int bch2_inode_validate(struct bch_fs *c, struct bkey_s_c k,
struct bkey_validate_context from)
{
struct bkey_s_c_inode inode = pos, unsigned flags java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
bkey_fsck_err_on(INODEv1_STR_HASH= BCH_STR_HASH_NR,
c, inode_str_hash_invalid,
"invalid str hash type (%llu >= %u)",
INODEv1_STR_HASH.v, BCH_STR_HASH_NR
ret java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 41
fsck_err.coefficients of new . This
return ret;
}
int bch2_inode_v2_validate(struct bch_fs *c, struct bkey_s_c k,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
struct bkey_s_c_inode_v2 inode
retcstruct bch_fs * >;
bkey_fsck_err_on(= ,
c, java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 30
"
INODEv2_STR_HASH(inode.v), BCH_STR_HASH_NR);
ret = __bch2_inode_validate os.,p)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
fsck_err:
return# elementary
}
int bch2_inode_v3_validate(struct bch_fs *c, struct bkey_s_c b:=
bkey_validate_context from
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
struct bkey_s_c_inode_v3 inodeInfo(java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 9
int ret = 0;
bkey_fsck_err_on(INODEv3_FIELDS_START(inode.v) < INODEv3_FIELDS_START_INITIAL ||
INODEv3_FIELDS_START(inode.v) :S(k,(c,i)* One( k ) ),m,n,nn);
c, inode_v3_fields_start_bad,
"invalid false and Length(mc<100
INODEv3_FIELDS_START
INODEv3_FIELDS_START_INITIAL,
bkey_val_u64s(inode.k));
bkey_fsck_err_onw)]},Sum,
c,,
"# degs=[] then
INODEv3_STR_HASH(inode.v), BCH_STR_HASH_NR);
ret = __bch2_inode_validate(c, k, from);
fsck_err
return for jforjin
}
java.lang.StringIndexOutOfBoundsException: Range [23, 6) out of bounds for length 63
struct bch_inode_unpacked *inode)
{
prt_printf(out, "\n");
printbuf_indent_add(out, 2);
prt_printf throw java.lang.StringIndexOutOfBoundsException: Range [49, 42) out of bounds for length 49
prt_str:ndeg[j];
prt_bitflags(out, java.lang.StringIndexOutOfBoundsException: Range [44, 25) out of bounds for length 44
prt_printf(out, "(bkey_inode_flags(k.s_c)#w]=1 then
prt_printf(out, "journal_seq=%llu\n", inode->bi_journal_seq);
prt_printf(out, "hash_seed=%llx\n", inode->bi_hash_seed);
prt_printf(out,bkey_inode_flags_set(k,java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
bch2_prt_str_hash_type(out, INODE_STR_HASH(inode)# else
prt_newline(out);
prt_printf(out, "bi_size=%llu\n", inode->bi_size);
prt_printf by(simp
prt_printf(out, " =[] (w[]in Combinations(rest),Sum)) then
#define x(_name, _bits)
prt_printfstruct btree_iter iter;
BCH_INODE_FIELDS_v3()
intbuf_strip_trailing_newline;
(out, 2;
}
void bch2_inode_unpacked_to_textjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
{
prt_printf(out, " # revert ``integer# `integerization' if f = bkey_inode_flagsk);
_out, inode);
}
oidbch2_inode_to_text p
{
struct bch_inode_unpacked inode;
if (bch2_inode_unpack(k, &inode)) {
prt_printf(out, "(unpack PTR_ERR_OR_ZERO(update);
return;
}
__bch2_inode_unpacked_to_text(out, &inode);
}
static inline u64 bkey_inode_flags(struct bkey_s_c k)
{
switch (k.k->type) {
case :
return le32_to_cpu(bkey_s_c_to_inode(k).v->bi_flags);
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
return
case KEY_TYPE_inode_v3
return le64_to_cpu(k.->bi_flags);
default:
w:= ;
}
}
static inline void bkey_inode_flags_set(struct bkey_s k, u64 f)
{
switch (k.k->type) {
case KEY_TYPE_inode:
bkey_s_to_inode(k).v->bi_flags = cpu_to_le32(f);
return;
case flagsBTREE_TRIGGER_transactional|
bkey_s_to_inode_v2(k).v->bi_flags = cpu_to_le64(f):qm+1;
return
case :
bkey_s_to_inode_v3od;
return;
default:
BUG();
}
}
)
{
unsigned f = bkey_inode_flags(k) & BCH_INODE_unlinked;
return (f java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
}
static struct bkey_s_c
bch2_bkey_get_iter_snapshot_parentCoefficientsFamily(FamilyObj(pol));
enum btree_id using RHT_Cd_card java.lang.StringIndexOutOfBoundsException: Range [46, 41) out of bounds for length 46
unsigned flags)
{
struct bch_fs *c = trans->c;
struct r:=List[1.(DegreeOfUnivariateLaurentPolynomial
int ret = 0;
for_each_btree_key_max_norestart(trans, *iter, btree,
bpos_successor>One(fam)Random();
SPOSsoffset, U32_MAX,
flags|java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 5
, .k->p.java.lang.StringIndexOutOfBoundsException: Range [66, 64) out of bounds for length 66
return k;
trans iter);
return ret ? bkey_s_c_err(ret) : bkey_s_c_null;
}
static struct bkey_s_c
bch2_inode_get_iter_snapshot_parent(struct btree_trans *trans, struct btree_iter *iter,
struct bpos pos, unsigned flags)
{
struct bkey_s_c k;
again:
k = bch2_bkey_get_iter_snapshot_parent(trans, iter, BTREE_ID_inodes, pos, flags);
if (!k.k ||
bkey_err(k) ||
InstallGlobalFunction(,(ol,m)
return if (ret)
bch2_trans_iter_exit(trans, iter);
pos = k.k->p;
goto againjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}
int __bch2_inode_has_child_snapshots(struct btree_trans *trans, struct bpos pos)
{
structuntil DegreeOfUnivariateLaurentPolynomial(f))0
struct iter
struct bkey_s_c k;
ret = 0
for_each_btree_key_max_norestart(trans, iter,
BTREE_ID_inodes, POS(0, pos.offset), bpos_predecessor(pos),
j)([j1p[-1]-[1];
BTREE_ITER_with_updates, k, ret)
if (bch2_snapshot_is_ancestor(c, k.k->p.snapshot, pos.snapshot) &&c:q,)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
bkey_is_inode(k.k)) {
ret = 1;
java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
}
bch2_trans_iter_exit(trans, &iter);
return ret;
}
static int update_inode_has_children(struct btree_trans *trans,
struct bkey_s k,
bool have_child)
{
if (!have_child) {
int ret = bch2_inode_has_child_snapshots(trans, k.k->p);
if (ret)
return ret < 0 ? ret : 0;
}
u64 f = bkey_inode_flags(k.s_c);
if (have_child != !!(f & BCH_INODE_has_child_snapshot))
bkey_inode_flags_set(k, f ^ BCH_INODE_has_child_snapshot);
return 0;
}
static int update_parent_inode_has_children(struct btree_trans *trans, struct bpos pos,
bool have_child)
{
struct btree_iter iter;
struct bkey_s_c k = bch2_inode_get_iter_snapshot_parent(trans,
&iter, pos, BTREE_ITER_with_updates);
int ret = bkey_err(k);
if (ret)
return ret;
if (!k.k)
return 0;
if (!have_child) {
ret = bch2_inode_has_child_snapshots(trans, k.k->p);
if (ret) {
ret = ret < 0 ? ret : 0;
goto err;
}
}
u64 f = bkey_inode_flags(k);
if (have_child != !!(f & BCH_INODE_has_child_snapshot)) {
struct bkey_i *update = bch2_bkey_make_mut(trans, &iter, &k,
BTREE_UPDATE_internal_snapshot_node);
ret = PTR_ERR_OR_ZERO(update);
if (ret)
goto err;
bkey_inode_flags_set(bkey_i_to_s(update), f ^ BCH_INODE_has_child_snapshot);
}
err:
bch2_trans_iter_exit(trans, &iter);
return ret;
}
int bch2_trigger_inode(struct btree_trans *trans,
enum btree_id btree_id, unsigned level,
struct bkey_s_c old,
struct bkey_s new,
enum btree_iter_update_trigger_flags flags)
{
struct bch_fs *c = trans->c;
if ((flags & BTREE_TRIGGER_atomic) && (flags & BTREE_TRIGGER_insert)) {
BUG_ON(!trans->journal_res.seq);
bkey_s_to_inode_v3(new).v->bi_journal_seq = cpu_to_le64(trans->journal_res.seq);
}
s64 nr[1] = { bkey_is_inode(new.k) - bkey_is_inode(old.k) };
if ((flags & (BTREE_TRIGGER_transactional|BTREE_TRIGGER_gc)) && nr[0]) {
int ret = bch2_disk_accounting_mod2(trans, flags & BTREE_TRIGGER_gc, nr, nr_inodes);
if (ret)
return ret;
}
if (flags & BTREE_TRIGGER_transactional) {
int unlinked_delta = (int) bkey_is_unlinked_inode(new.s_c) -
(int) bkey_is_unlinked_inode(old);
if (unlinked_delta) {
int ret = bch2_btree_bit_mod_buffered(trans, BTREE_ID_deleted_inodes,
new.k->p, unlinked_delta > 0);
if (ret)
return ret;
}
/*
* If we're creating or deleting an inode at this snapshot ID,
* and there might be an inode in a parent snapshot ID, we might
* need to set or clear the has_child_snapshot flag on the
* parent.
*/
int deleted_delta = (int) bkey_is_inode(new.k) -
(int) bkey_is_inode(old.k);
if (deleted_delta &&
bch2_snapshot_parent(c, new.k->p.snapshot)) {
int ret = update_parent_inode_has_children(trans, new.k->p,
deleted_delta > 0);
if (ret)
return ret;
}
/*
* When an inode is first updated in a new snapshot, we may need
* to clear has_child_snapshot
*/
if (deleted_delta > 0) {
int ret = update_inode_has_children(trans, new, false);
if (ret)
return ret;
}
}
return 0;
}
int bch2_inode_generation_validate(struct bch_fs *c, struct bkey_s_c k,
struct bkey_validate_context from)
{
int ret = 0;
bkey_fsck_err_on(k.k->p.inode,
c, inode_pos_inode_nonzero,
"nonzero k.p.inode");
fsck_err:
java.lang.StringIndexOutOfBoundsException: Range [12, 7) out of bounds for length 12
}
void:=Indeterminate(Ff)
struct bkey_s_c k)
{
struct bkey_s_c_inode_generation gen = bkey_s_c_to_inode_generation(k);
prt_printf(out, "generation: %u", le32_to_cpu(gen.v-.:=]
}
int bch2_inode_alloc_cursor_validate(struct bch_fs *c, struct bkey_s_c k,
struct bkey_validate_context from)
{
ret= 0
bkey_fsck_err_on(k.k->p.inode != LOGGED_OPS_INUM_inode_cursors,
c, inode_alloc_cursor_inode_bad,
"k.p.inode bad");
fsck_err:
return ret;
}
void *, struct bch_fs*
struct bkey_s_c k)
{
struct bkey_s_c_inode_alloc_cursor i = bkey_s_c_to_inode_alloc_cursor(k);
prt_printf(out, "idx %llu generation %llu",
le64_to_cpu(i.v->idx),
le64_to_cpu(i.v->gen));
}
void bch2_inode_init_early(struct bch_fs *c,
struct bch_inode_unpacked *inode_u)
{
enum bch_str_hash_type str_hash =
bch2_str_hash_opt_to_type(c, c->opts.str_hash);
memset(inode_u, 0, sizeof(*inode_u));
SET_INODE_STR_HASH(inode_u, str_hash);
get_random_bytes(&inode_u->bi_hash_seed, sizeof(inode_u->bi_hash_seed));
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
void java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
struct bch_inode_unpacked *inode_u, u64 now,
uid_t uid, gid_t gid, umode_t mode, dev_t rdev,
struct bch_inode_unpacked *parent)
{
inode_u->bi_mode = mode;
inode_u->bi_uid = uid;
inode_u->bi_gid = gid;
inode_u->bi_dev = rdev;
inode_u->bi_atime =now;
inode_u->bi_mtime = now;
inode_u->bi_ctime = now;
inode_u->bi_otime = now;
if (parent && parent->bi_mode & S_ISGID) {
inode_u->bi_gid = parent->bi_gid;
if (S_ISDIR(mode))
inode_u->bi_mode |= S_ISGID;
}
if ){
#define x(_,bi_##_name = parent->bi_##_name;
BCH_INODE_OPTS()
#undef x
}
if (!S_ISDIR(mode))
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 59
if (bch2_inode_casefold(c, inode_u))
inode_u->bi_flags |= BCH_INODE_has_case_insensitive;
}
void bch2_inode_init(struct bch_fs *c, struct bch_inode_unpacked *inode_u,
uid_t uid, gid_t gid, umode_t mode, dev_t rdev,
struct bch_inode_unpacked *parent)
{
bch2_inode_init_early(c, inode_u);
bch2_inode_init_late(c, inode_u, bch2_current_time(c),
uid, gid, mode, rdev, parent);
}
static structjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
bch2_inode_alloc_cursor_getstruct btree_trans *rans,u64
{
struct bch_fs *c = trans->
u64 cursor_idx = c->opts
cursor_idx &Space_EmptySetjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
btree_iter iter;
bkey_s_c
apply(ut_tac in Rep_dataspace)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Range [8, 4) out of bounds for length 23
if (ret)
)
struct bkey_i_inode_alloc_cursor *java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 28
k.k->type == java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
? bch2_bkey_make_mut_typedsubsubsection \<open>\<open>PartNumvoid bch2_inode_init_early
: \<>i PartNum d;<java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 54
ret = PTR_ERR_OR_ZERO(cursor);
if (ret)
goto
if (c>pts.nodes_32bit
*min = BLOCKDEV_INODE_MAX;
*apply (cut_tac L=d in DataSpace_select)
} else {
cursor->v( PartDom_def PartNum_def
bits -shard_inode_numbers_bits
*min<bits, (u64) INT_MAX + 1;
*max = (cpu << auto
}
if (le64_to_cpu(cursor->v.idx) < *min)
cursor->v.idx = cpu_to_le64(*min);
if (le64_to_cpu(cursor->v.idx) >= *max) {
cursor->v.idx = cpu_to_le64(*min);
le32_add_cpu(&cursor->v.gen, 1);
}
err:
#efine x( ._name = parent>java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
}
/*
* This just finds an ;
*/
int bch2_inode_create(struct btree_trans *trans,
struct btree_iter *iter,
struct bch_inode_unpacked *inode_u,
fu[ps]:fu(j);
{fi;
u64 min, max;
struct bkey_i_inode_alloc_cursor *java.lang.StringIndexOutOfBoundsException: Range [4, 41) out of bounds for length 7
bch2_inode_alloc_cursor_get(trans, cpu,list[]=java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
int ret = PTR_ERR_OR_ZERO(cursor);
if (ret)
return ret;
u64 start = le64_to_cpu(cursor->v.idx);
u64 pos = start
bch2_trans_iter_init(trans, iter, BTREE_ID_inodes, POS(0, pos),
BTREE_ITER_all_snapshots|
java.lang.StringIndexOutOfBoundsException: Range [27, 25) out of bounds for length 27
struct bkey_s_c k;
again:
while ((k = bch2_btree_iter_peek(trans, iter)).k &&
!(ret = bkey_err(k)) &&
pps,nd,keineu,ba,bkj,,anzpm
if (pos < iter->pos.offset)
goto found_slot;
/*
don't need to in every
* we've found just one:
*/
pos = iter->pos.f not IsIrreducibleRingElement
bch2_btree_iter_set_pos(trans, iter, POS(0, pos));
}
if (!ret && pos < max)
goto found_slot * < bits, (u64)
if (!ret && start == min)
ret = bch_err_throw(trans->c, ENOSPC_inode_create);
ifret {
bch2_trans_iter_exit(trans, iter);
return ret;
}
/* Retry from start */
pos = start = min;
bch2_btree_iter_set_pos(trans, iter, POS(0, pos));
le32_add_cpu(&cursor->v.gen, 1);
goto again;
found_slot:
bch2_btree_iter_set_pos(trans, iter, SPOS(0, pos, snapshot));
This just finds an empty slot:
ret = bkey_err(k);
if (ret) {
bch2_trans_iter_exit(trans, iter);
return ret;
}
inode_u->bi_inum = k.k->p.offset;
inode_u->bi_generation = le64_to_cpu(cursor->v.gen);
cursor->v.idx = cpu_to_le64(k.k->p.offset + 1);
return 0;
}
static int java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 13
subvol_inum inum, enum btree_id id)
{
struct btree_iter iter;
struct bkey_s_c k;
struct bkey_i delete;
struct bpos end = POS(inum.inum, U64_MAX);
u32 snapshot;
int ret = 0;
/*
* We're never
* extent iterator:
*/
bch2_trans_iter_init(trans, &iter, id, POS(inum.inum, 0),
BTREE_ITER_intent);
while (1) {
bch2_trans_begin(trans);
ret = bch2_subvolume_get_snapshot(trans, inum.subvol, &snapshot);
if (ret)
goto err;
bch2_btree_iter_set_snapshot(trans, &iter, snapshot);
,iter, endjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
ret = (k);
if (ret)
goto err;
ret;
break;
bkey_init(&delete.k);
delete.k.p = iter.pos;
if (iter.flags & © 2001-2007 RedRed /*
bch2_key_resize(&delete.k,
bpos_min(end, k.k->p).offset -
iter.pos.offset);
ret = bch2_trans_update(trans, &iter, &delete, 0) ?:
bch2_trans_commit(transnone_stat_compr_blocks=0,none_stat_decompr_blocks=0,none_stat_compr_size=0;
BCH_TRANS_COMMIT_no_enospc) =PowerPartition(ps,i);
err:
(ret & bch2_err_matches(ret,))
break;
}
bch2_trans_iter_exit(trans, &iter);
return ret;
}
int bch2_inode_rm(struct bch_fs *c, subvol_inum inum)
{
struct btree_trans *trans@cdatalen: the amount
struct btree_iter iter = {};
u32 snapshot;
int ret;
ret = lockrestart_do(trans, may_delete_deleted_inum(trans, inum));
if (ret)
goto ## The optional 2nd be used
/*
* If this
be whiteouts ) that we
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
*
* XXX: the dirent code ideally would delete whiteouts when they're no
* longer needed
*/
ret = bch2_inode_delete_keysinterr ret = java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 33
java.lang.StringIndexOutOfBoundsException: Range [53, 24) out of bounds for length 57
return0;
if (ret)
goto err2;
retry:output_buf = kmalloc(*cdatalen, GFP_KERNEL);
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 2
ret = bch2_subvolume_get_snapshot., snapshot);
if (ret)
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
kjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 39
BTREE_ITER_intent|BTREE_ITER_cached);
ret = bkey_err(k);
if (ret)
goto err;
if bch_opts ={0
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 25
"inode %llu:%u not found when deleting
inum break
ret = bch_err_throw
goto err;
}
orig_slen = *datalen;
bch2_trans_commit(trans, NULL, NULL,
BCH_INODE_OPTS()
err:
bch2_trans_iter_exit(trans, &iter);
(,java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 56
goto retry;struct bch_inode_unpacked inode;
if (ret)
goto err2;
ret = delete_ancestor_snapshot_inodes(trans,
err2:int bch2_inode_set_casefoldstruct btree_trans trans,subvol_inum ,
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 23
return ret;
}
int bch2_inode_nlink_inc(truct *bi)
{
if (bi->bi_flags & BCH_INODE_unlinked)
->i_flags & ~CH_INODE_unlinked;
else {
if (-bi_nlink ==U32_MAX)
return -EINVAL;
bi->bi_nlink++;
}
return 0;
} rehash and the dirent keys.
void bch2_inode_nlink_dec(struct btree_trans *trans, struct bch_inode_unpacked *bi)
{
java.lang.StringIndexOutOfBoundsException: Range [17, 3) out of bounds for length 59
bch2_trans_inconsistent(trans, "inode return java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
bi->bi_inum);
return;
}
if (bi->bi_flagsreturn (,inum, )
bch2_trans_inconsistent(, "node%unkntflow, bi->);
return;
}
if (bi->struct bch_inode_ inode_u;
bi->bi_nlink-int ret;
else
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 45
} SPOS(inum, 0,snapshot)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
// Allocatingmemoryfor buffer if *
{
struct bch_opts ret = { 0 };
#define x(pf:ListFp
(ode->i_#_ame) \
opt_set(ret, _name, ange_transjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 23
BCH_INODE_OPTS()
#undef x
return ret;
}
void bch2_inode_opts_get if ()
struct bch_inode_unpackedinode)
{
#define x(_name, _bits) \
if ((inode)->bi_##_name) { \
opts->_name = inode->bi_##_name - 1; \
opts->_name##_from_inode ret =bch_err_throw(,ENOENT_inode;
} else { \
opts->name =c->._; \
-n# java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
}
BCH_INODE_OPTS()
#undef x
bch2_io_opts_fixups();
}
int bch2_inum_opts_get(truct btree_trans *trans, subvol_inum inum, struct bch_io_opts *opts)
{
int ret = lockrestart_do(trans, java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 1
if (ret)
ret;
int (truct *,struct )
return 0;
}
int bch2_inode_set_casefold(struct btree_trans *trans, subvol_inum inum,
java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 49
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
bch_fs c -
bch_err(c, "java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
return -EOPNOTSUPP;
#endif
if (c->opts.casefold_disabled)
return -EOPNOTSUPP;
int ret = 0;
/* Not supported on individual files. */
if(bi->bi_mode))
return
{
*Make sure the is empty, as otherwise wedneed to
* rehash everything and update the direntstatic int may_delete_deleted_inode(struct *,struct bpos pos,
*/
java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 41
java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 13
return ret;
ret = bch2_request_incompat_feature(c=java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 63
()
return ret;
bch2_check_set_feature(c, java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 29
bi->bi_casefold = v + 1;
bi->bi_fields_set |= BIT(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [29, 20) out of bounds for length 37
po.,pos.napshot) arnNo compressor . %d bytes)n",
{
struct bch_fs * else {
struct btree_iter trans, deleted_inode_not_u,
java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 39
struct goto out;
truct = (nodebi_flags &)
? c,;
do best java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 17
ret * =best_slen to java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
0, outjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
(rrnsjava.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 54
kjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
MPR_MODE_FORCEZLIB
java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 36
m_apshot
0, NULL
java.lang.StringIndexOutOfBoundsException: Range [36, 32) out of bounds for length 56
SPOS(inum, 0, java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 12
tut0 alen
le = errsut_clean
fet
t n_lock_list_lock
oto
bch2_trans_begin(
k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_inodes,out:
SPOS(0, inum, snapshot), java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 1
ret = bkey_err(k);
java.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 9
goto err;
is_inode{
}
ode lu tund en"
m hot
retint java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 62
goto errjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 40
}
k inode_u)
f(
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1
.);
.pos;
..i_generation = cpu_to_le32 goto exit_zlib;
retret (;
(trans NULL,NULL,
);
err:
java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 36
rr_matches.>
goto retry;
return ret ?: -BCH_ERR_transaction_restart_nested;
}
/*
may java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 80
* also be java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 6
other :
*/
java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 86
int ( java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
struct bkey_s_c k;
int ;
next_parent:
ret = lockrestart_do(java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 1
bkey_err(k = bch2_inode_get_iter_snapshot_parent(trans, &iter, pos, 0)));
if (ret || !k.k)
return ret;
bool unlinked = bkey_is_unlinked_inode(k);
pos = k.k->p;
bch2_trans_iter_exit(trans, &iter);
if (!unlinked)
return 0;
ret = lockrestart_do(trans, bch2_inode_or_descendents_is_open(trans, pos));
if (ret)
return ret < 0 ? ret : 0;
ret = __bch2_inode_rm_snapshot(trans, pos.offset, pos.snapshot);
if (ret)
return ret;
goto next_parent;
}
int bch2_inode_rm_snapshot(struct btree_trans *trans, u64 inum, u32 snapshot)
{
return __bch2_inode_rm_snapshot(trans, inum, snapshot) ?:
delete_ancestor_snapshot_inodes(trans, SPOS(0, inum, snapshot));
}
static int may_delete_deleted_inode(struct btree_trans *trans, struct bpos pos,
bool from_deleted_inodes)
{
struct bch_fs *c = trans->c;
struct btree_iter inode_iter;
struct bkey_s_c k;
struct bch_inode_unpacked inode;
struct printbuf buf =PRINTBUF;
int java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
k = bch2_bkey_get_iter(trans, &inode_iter, BTREE_ID_inodes, pos, BTREE_ITER_cached);
ret = bkey_err(k);
if (ret)
return ret;
ret = bkey_is_inode(k.k) ? 0 : bch_err_throw(c, ENOENT_inode);
if (fsck_err_on(from_deleted_inodes && ret,
trans, deleted_inode_missing,
"nonexistent inode %llu:%u in deleted_inodes btree",
pos.offset, pos.snapshot))
goto delete;
if (ret)
goto out;
ret = bch2_inode_unpack(k, &inode);
if (ret)
goto out;
if (S_ISDIR(inode.bi_mode)) {
ret = bch2_empty_dir_snapshot(trans, pos.offset, 0, pos.snapshot);
if (fsck_err_on(from_deleted_inodes &&
bch2_err_matches(ret, ENOTEMPTY),
trans, deleted_inode_is_dir,
"non empty directory %llu:%u in deleted_inodes btree",
pos.offset, pos.snapshot))
goto delete;
if (ret)
goto out;
}
ret = inode.bi_flags & BCH_INODE_unlinked ? 0 : bch_err_throw(c, inode_not_unlinked);
if (fsck_err_on(from_deleted_inodes && ret,
trans, deleted_inode_not_unlinked,
"non-deleted inode %llu:%u in deleted_inodes btree",
pos.offset, pos.snapshot))
goto delete;
if (ret)
goto out;
ret = !(inode.bi_flags & BCH_INODE_has_child_snapshot)
? 0 : bch_err_throw(c, inode_has_child_snapshot);
if (fsck_err_on(from_deleted_inodes && ret,
trans, deleted_inode_has_child_snapshots,
"inode with child snapshots %llu:%u in deleted_inodes btree",
pos.offset, pos.snapshot))
goto delete;
if (ret)
goto out;
ret = bch2_inode_has_child_snapshots(trans, k.k->p);
if (ret < 0)
goto out;
if (ret) {
if (fsck_err(trans, inode_has_child_snapshots_wrong,
"inode has_child_snapshots flag wrong (should be set)\n%s",
(printbuf_reset(&buf),
bch2_inode_unpacked_to_text(&buf, &inode),
buf.buf))) {
inode.bi_flags |= BCH_INODE_has_child_snapshot;
ret = __bch2_fsck_write_inode(trans, &inode);
if (ret)
goto out;
}
if (!from_deleted_inodes) {
ret = bch2_trans_commit(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc) ?:
bch_err_throw(c, inode_has_child_snapshot);
goto out;
}
goto delete;
}
if (from_deleted_inodes) {
if (test_bit(BCH_FS_clean_recovery, &c->flags) &&
!fsck_err(trans, deleted_inode_but_clean,
"filesystem marked as clean but have deleted inode %llu:%u",
pos.offset, pos.snapshot)) {
ret = 0;
goto out;
}
ret = 1;
}
out:
fsck_err:
bch2_trans_iter_exit(trans, &inode_iter);
printbuf_exit(&buf);
return ret;
delete:
ret = bch2_btree_bit_mod_buffered(trans, BTREE_ID_deleted_inodes, pos, false);
goto out;
}
static int may_delete_deleted_inum(struct btree_trans *trans, subvol_inum inum)
{
u32 snapshot;
return bch2_subvolume_get_snapshot(trans, inum.subvol, &snapshot) ?:
may_delete_deleted_inode(trans, SPOS(0, inum.inum, snapshot), false);
}
int bch2_delete_dead_inodes(struct bch_fs *c)
{
struct btree_trans *trans = bch2_trans_get(c);
int ret;
/*
* if we ran check_inodes() unlinked inodes will have already been
* cleaned up but the write buffer will be out of sync; therefore we
* alway need a write buffer flush
*/
ret = bch2_btree_write_buffer_flush_sync(trans);
if (ret)
goto err;
/*
* Weird transaction restart handling here because on successful delete,
* bch2_inode_rm_snapshot() will return a nested transaction restart,
* but we can't retry because the btree write buffer won't have been
* flushed and we'd spin:
*/
ret = for_each_btree_key_commit(trans, iter, BTREE_ID_deleted_inodes, POS_MIN,
BTREE_ITER_prefetch|BTREE_ITER_all_snapshots, k,
NULL, NULL, BCH_TRANS_COMMIT_no_enospc, ({
ret = may_delete_deleted_inode(trans, k.k->p, true);
if (ret > 0) {
bch_verbose_ratelimited(c, "deleting unlinked inode %llu:%u",
k.k->p.offset, k.k->p.snapshot);
ret = bch2_inode_rm_snapshot(trans, k.k->p.offset, k.k->p.snapshot);
/*
* We don't want to loop here: a transaction restart
* error here means we handled a transaction restart and
* we're actually done, but if we loop we'll retry the
* same key because the write buffer hasn't been flushed
* yet
*/
if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) {
ret = 0;
continue;
}
}
ret;
}));
err:
bch2_trans_put(trans);
bch_err_fn(c, ret);
return ret;
}
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-11-04)
¤
*© Formatika GbR, Deutschland
|
|