reflink.c (792031116bee35e13be7c8ae8cf1b8eec141b136) reflink.c (facafdcbc157686311dbe58649ef9d29fcf8e610)
1// SPDX-License-Identifier: GPL-2.0
2#include "bcachefs.h"
3#include "bkey_buf.h"
4#include "btree_update.h"
5#include "buckets.h"
6#include "extents.h"
7#include "inode.h"
8#include "io.h"

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

21 default:
22 return 0;
23 }
24}
25
26/* reflink pointers */
27
28int bch2_reflink_p_invalid(const struct bch_fs *c, struct bkey_s_c k,
1// SPDX-License-Identifier: GPL-2.0
2#include "bcachefs.h"
3#include "bkey_buf.h"
4#include "btree_update.h"
5#include "buckets.h"
6#include "extents.h"
7#include "inode.h"
8#include "io.h"

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

21 default:
22 return 0;
23 }
24}
25
26/* reflink pointers */
27
28int bch2_reflink_p_invalid(const struct bch_fs *c, struct bkey_s_c k,
29 int rw, struct printbuf *err)
29 unsigned flags, struct printbuf *err)
30{
31 struct bkey_s_c_reflink_p p = bkey_s_c_to_reflink_p(k);
32
33 if (bkey_val_bytes(p.k) != sizeof(*p.v)) {
34 prt_printf(err, "incorrect value size (%zu != %zu)",
35 bkey_val_bytes(p.k), sizeof(*p.v));
36 return -EINVAL;
37 }

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

73
74 bch2_key_resize(l.k, l.k->size + r.k->size);
75 return true;
76}
77
78/* indirect extents */
79
80int bch2_reflink_v_invalid(const struct bch_fs *c, struct bkey_s_c k,
30{
31 struct bkey_s_c_reflink_p p = bkey_s_c_to_reflink_p(k);
32
33 if (bkey_val_bytes(p.k) != sizeof(*p.v)) {
34 prt_printf(err, "incorrect value size (%zu != %zu)",
35 bkey_val_bytes(p.k), sizeof(*p.v));
36 return -EINVAL;
37 }

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

73
74 bch2_key_resize(l.k, l.k->size + r.k->size);
75 return true;
76}
77
78/* indirect extents */
79
80int bch2_reflink_v_invalid(const struct bch_fs *c, struct bkey_s_c k,
81 int rw, struct printbuf *err)
81 unsigned flags, struct printbuf *err)
82{
83 struct bkey_s_c_reflink_v r = bkey_s_c_to_reflink_v(k);
84
85 if (bkey_val_bytes(r.k) < sizeof(*r.v)) {
86 prt_printf(err, "incorrect value size (%zu < %zu)",
87 bkey_val_bytes(r.k), sizeof(*r.v));
88 return -BCH_ERR_invalid_bkey;
89 }
90
82{
83 struct bkey_s_c_reflink_v r = bkey_s_c_to_reflink_v(k);
84
85 if (bkey_val_bytes(r.k) < sizeof(*r.v)) {
86 prt_printf(err, "incorrect value size (%zu < %zu)",
87 bkey_val_bytes(r.k), sizeof(*r.v));
88 return -BCH_ERR_invalid_bkey;
89 }
90
91 return bch2_bkey_ptrs_invalid(c, k, rw, err);
91 return bch2_bkey_ptrs_invalid(c, k, flags, err);
92}
93
94void bch2_reflink_v_to_text(struct printbuf *out, struct bch_fs *c,
95 struct bkey_s_c k)
96{
97 struct bkey_s_c_reflink_v r = bkey_s_c_to_reflink_v(k);
98
99 prt_printf(out, "refcount: %llu ", le64_to_cpu(r.v->refcount));

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

126 }
127
128 return bch2_trans_mark_extent(trans, btree_id, level, old, new, flags);
129}
130
131/* indirect inline data */
132
133int bch2_indirect_inline_data_invalid(const struct bch_fs *c, struct bkey_s_c k,
92}
93
94void bch2_reflink_v_to_text(struct printbuf *out, struct bch_fs *c,
95 struct bkey_s_c k)
96{
97 struct bkey_s_c_reflink_v r = bkey_s_c_to_reflink_v(k);
98
99 prt_printf(out, "refcount: %llu ", le64_to_cpu(r.v->refcount));

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

126 }
127
128 return bch2_trans_mark_extent(trans, btree_id, level, old, new, flags);
129}
130
131/* indirect inline data */
132
133int bch2_indirect_inline_data_invalid(const struct bch_fs *c, struct bkey_s_c k,
134 int rw, struct printbuf *err)
134 unsigned flags, struct printbuf *err)
135{
136 if (bkey_val_bytes(k.k) < sizeof(struct bch_indirect_inline_data)) {
137 prt_printf(err, "incorrect value size (%zu < %zu)",
138 bkey_val_bytes(k.k), sizeof(struct bch_indirect_inline_data));
139 return -BCH_ERR_invalid_bkey;
140 }
141
142 return 0;

--- 280 unchanged lines hidden ---
135{
136 if (bkey_val_bytes(k.k) < sizeof(struct bch_indirect_inline_data)) {
137 prt_printf(err, "incorrect value size (%zu < %zu)",
138 bkey_val_bytes(k.k), sizeof(struct bch_indirect_inline_data));
139 return -BCH_ERR_invalid_bkey;
140 }
141
142 return 0;

--- 280 unchanged lines hidden ---