]> Git Repo - linux.git/blob - fs/bcachefs/fs-common.c
Linux 6.14-rc3
[linux.git] / fs / bcachefs / fs-common.c
1 // SPDX-License-Identifier: GPL-2.0
2
3 #include "bcachefs.h"
4 #include "acl.h"
5 #include "btree_update.h"
6 #include "dirent.h"
7 #include "fs-common.h"
8 #include "inode.h"
9 #include "subvolume.h"
10 #include "xattr.h"
11
12 #include <linux/posix_acl.h>
13
14 static inline int is_subdir_for_nlink(struct bch_inode_unpacked *inode)
15 {
16         return S_ISDIR(inode->bi_mode) && !inode->bi_subvol;
17 }
18
19 int bch2_create_trans(struct btree_trans *trans,
20                       subvol_inum dir,
21                       struct bch_inode_unpacked *dir_u,
22                       struct bch_inode_unpacked *new_inode,
23                       const struct qstr *name,
24                       uid_t uid, gid_t gid, umode_t mode, dev_t rdev,
25                       struct posix_acl *default_acl,
26                       struct posix_acl *acl,
27                       subvol_inum snapshot_src,
28                       unsigned flags)
29 {
30         struct bch_fs *c = trans->c;
31         struct btree_iter dir_iter = { NULL };
32         struct btree_iter inode_iter = { NULL };
33         subvol_inum new_inum = dir;
34         u64 now = bch2_current_time(c);
35         u64 cpu = raw_smp_processor_id();
36         u64 dir_target;
37         u32 snapshot;
38         unsigned dir_type = mode_to_type(mode);
39         int ret;
40
41         ret = bch2_subvolume_get_snapshot(trans, dir.subvol, &snapshot);
42         if (ret)
43                 goto err;
44
45         ret = bch2_inode_peek(trans, &dir_iter, dir_u, dir,
46                               BTREE_ITER_intent|BTREE_ITER_with_updates);
47         if (ret)
48                 goto err;
49
50         if (!(flags & BCH_CREATE_SNAPSHOT)) {
51                 /* Normal create path - allocate a new inode: */
52                 bch2_inode_init_late(new_inode, now, uid, gid, mode, rdev, dir_u);
53
54                 if (flags & BCH_CREATE_TMPFILE)
55                         new_inode->bi_flags |= BCH_INODE_unlinked;
56
57                 ret = bch2_inode_create(trans, &inode_iter, new_inode, snapshot, cpu);
58                 if (ret)
59                         goto err;
60
61                 snapshot_src = (subvol_inum) { 0 };
62         } else {
63                 /*
64                  * Creating a snapshot - we're not allocating a new inode, but
65                  * we do have to lookup the root inode of the subvolume we're
66                  * snapshotting and update it (in the new snapshot):
67                  */
68
69                 if (!snapshot_src.inum) {
70                         /* Inode wasn't specified, just snapshot: */
71                         struct bch_subvolume s;
72                         ret = bch2_subvolume_get(trans, snapshot_src.subvol, true, &s);
73                         if (ret)
74                                 goto err;
75
76                         snapshot_src.inum = le64_to_cpu(s.inode);
77                 }
78
79                 ret = bch2_inode_peek(trans, &inode_iter, new_inode, snapshot_src,
80                                       BTREE_ITER_intent);
81                 if (ret)
82                         goto err;
83
84                 if (new_inode->bi_subvol != snapshot_src.subvol) {
85                         /* Not a subvolume root: */
86                         ret = -EINVAL;
87                         goto err;
88                 }
89
90                 /*
91                  * If we're not root, we have to own the subvolume being
92                  * snapshotted:
93                  */
94                 if (uid && new_inode->bi_uid != uid) {
95                         ret = -EPERM;
96                         goto err;
97                 }
98
99                 flags |= BCH_CREATE_SUBVOL;
100         }
101
102         new_inum.inum   = new_inode->bi_inum;
103         dir_target      = new_inode->bi_inum;
104
105         if (flags & BCH_CREATE_SUBVOL) {
106                 u32 new_subvol, dir_snapshot;
107
108                 ret = bch2_subvolume_create(trans, new_inode->bi_inum,
109                                             dir.subvol,
110                                             snapshot_src.subvol,
111                                             &new_subvol, &snapshot,
112                                             (flags & BCH_CREATE_SNAPSHOT_RO) != 0);
113                 if (ret)
114                         goto err;
115
116                 new_inode->bi_parent_subvol     = dir.subvol;
117                 new_inode->bi_subvol            = new_subvol;
118                 new_inum.subvol                 = new_subvol;
119                 dir_target                      = new_subvol;
120                 dir_type                        = DT_SUBVOL;
121
122                 ret = bch2_subvolume_get_snapshot(trans, dir.subvol, &dir_snapshot);
123                 if (ret)
124                         goto err;
125
126                 bch2_btree_iter_set_snapshot(&dir_iter, dir_snapshot);
127                 ret = bch2_btree_iter_traverse(&dir_iter);
128                 if (ret)
129                         goto err;
130         }
131
132         if (!(flags & BCH_CREATE_SNAPSHOT)) {
133                 if (default_acl) {
134                         ret = bch2_set_acl_trans(trans, new_inum, new_inode,
135                                                  default_acl, ACL_TYPE_DEFAULT);
136                         if (ret)
137                                 goto err;
138                 }
139
140                 if (acl) {
141                         ret = bch2_set_acl_trans(trans, new_inum, new_inode,
142                                                  acl, ACL_TYPE_ACCESS);
143                         if (ret)
144                                 goto err;
145                 }
146         }
147
148         if (!(flags & BCH_CREATE_TMPFILE)) {
149                 struct bch_hash_info dir_hash = bch2_hash_info_init(c, dir_u);
150                 u64 dir_offset;
151
152                 if (is_subdir_for_nlink(new_inode))
153                         dir_u->bi_nlink++;
154                 dir_u->bi_mtime = dir_u->bi_ctime = now;
155                 dir_u->bi_size += dirent_occupied_size(name);
156
157                 ret = bch2_inode_write(trans, &dir_iter, dir_u);
158                 if (ret)
159                         goto err;
160
161                 ret = bch2_dirent_create(trans, dir, &dir_hash,
162                                          dir_type,
163                                          name,
164                                          dir_target,
165                                          &dir_offset,
166                                          STR_HASH_must_create|BTREE_ITER_with_updates);
167                 if (ret)
168                         goto err;
169
170                 new_inode->bi_dir               = dir_u->bi_inum;
171                 new_inode->bi_dir_offset        = dir_offset;
172         }
173
174         if (S_ISDIR(mode) &&
175             !new_inode->bi_subvol)
176                 new_inode->bi_depth = dir_u->bi_depth + 1;
177
178         inode_iter.flags &= ~BTREE_ITER_all_snapshots;
179         bch2_btree_iter_set_snapshot(&inode_iter, snapshot);
180
181         ret   = bch2_btree_iter_traverse(&inode_iter) ?:
182                 bch2_inode_write(trans, &inode_iter, new_inode);
183 err:
184         bch2_trans_iter_exit(trans, &inode_iter);
185         bch2_trans_iter_exit(trans, &dir_iter);
186         return ret;
187 }
188
189 int bch2_link_trans(struct btree_trans *trans,
190                     subvol_inum dir,  struct bch_inode_unpacked *dir_u,
191                     subvol_inum inum, struct bch_inode_unpacked *inode_u,
192                     const struct qstr *name)
193 {
194         struct bch_fs *c = trans->c;
195         struct btree_iter dir_iter = { NULL };
196         struct btree_iter inode_iter = { NULL };
197         struct bch_hash_info dir_hash;
198         u64 now = bch2_current_time(c);
199         u64 dir_offset = 0;
200         int ret;
201
202         if (dir.subvol != inum.subvol)
203                 return -EXDEV;
204
205         ret = bch2_inode_peek(trans, &inode_iter, inode_u, inum, BTREE_ITER_intent);
206         if (ret)
207                 return ret;
208
209         inode_u->bi_ctime = now;
210         ret = bch2_inode_nlink_inc(inode_u);
211         if (ret)
212                 goto err;
213
214         ret = bch2_inode_peek(trans, &dir_iter, dir_u, dir, BTREE_ITER_intent);
215         if (ret)
216                 goto err;
217
218         if (bch2_reinherit_attrs(inode_u, dir_u)) {
219                 ret = -EXDEV;
220                 goto err;
221         }
222
223         dir_u->bi_mtime = dir_u->bi_ctime = now;
224         dir_u->bi_size += dirent_occupied_size(name);
225
226         dir_hash = bch2_hash_info_init(c, dir_u);
227
228         ret = bch2_dirent_create(trans, dir, &dir_hash,
229                                  mode_to_type(inode_u->bi_mode),
230                                  name, inum.inum, &dir_offset,
231                                  STR_HASH_must_create);
232         if (ret)
233                 goto err;
234
235         inode_u->bi_dir         = dir.inum;
236         inode_u->bi_dir_offset  = dir_offset;
237
238         ret =   bch2_inode_write(trans, &dir_iter, dir_u) ?:
239                 bch2_inode_write(trans, &inode_iter, inode_u);
240 err:
241         bch2_trans_iter_exit(trans, &dir_iter);
242         bch2_trans_iter_exit(trans, &inode_iter);
243         return ret;
244 }
245
246 int bch2_unlink_trans(struct btree_trans *trans,
247                       subvol_inum dir,
248                       struct bch_inode_unpacked *dir_u,
249                       struct bch_inode_unpacked *inode_u,
250                       const struct qstr *name,
251                       bool deleting_subvol)
252 {
253         struct bch_fs *c = trans->c;
254         struct btree_iter dir_iter = { NULL };
255         struct btree_iter dirent_iter = { NULL };
256         struct btree_iter inode_iter = { NULL };
257         struct bch_hash_info dir_hash;
258         subvol_inum inum;
259         u64 now = bch2_current_time(c);
260         struct bkey_s_c k;
261         int ret;
262
263         ret = bch2_inode_peek(trans, &dir_iter, dir_u, dir, BTREE_ITER_intent);
264         if (ret)
265                 goto err;
266
267         dir_hash = bch2_hash_info_init(c, dir_u);
268
269         ret = bch2_dirent_lookup_trans(trans, &dirent_iter, dir, &dir_hash,
270                                        name, &inum, BTREE_ITER_intent);
271         if (ret)
272                 goto err;
273
274         ret = bch2_inode_peek(trans, &inode_iter, inode_u, inum,
275                               BTREE_ITER_intent);
276         if (ret)
277                 goto err;
278
279         if (!deleting_subvol && S_ISDIR(inode_u->bi_mode)) {
280                 ret = bch2_empty_dir_trans(trans, inum);
281                 if (ret)
282                         goto err;
283         }
284
285         if (deleting_subvol && !inode_u->bi_subvol) {
286                 ret = -BCH_ERR_ENOENT_not_subvol;
287                 goto err;
288         }
289
290         if (inode_u->bi_subvol) {
291                 /* Recursive subvolume destroy not allowed (yet?) */
292                 ret = bch2_subvol_has_children(trans, inode_u->bi_subvol);
293                 if (ret)
294                         goto err;
295         }
296
297         if (deleting_subvol || inode_u->bi_subvol) {
298                 ret = bch2_subvolume_unlink(trans, inode_u->bi_subvol);
299                 if (ret)
300                         goto err;
301
302                 k = bch2_btree_iter_peek_slot(&dirent_iter);
303                 ret = bkey_err(k);
304                 if (ret)
305                         goto err;
306
307                 /*
308                  * If we're deleting a subvolume, we need to really delete the
309                  * dirent, not just emit a whiteout in the current snapshot:
310                  */
311                 bch2_btree_iter_set_snapshot(&dirent_iter, k.k->p.snapshot);
312                 ret = bch2_btree_iter_traverse(&dirent_iter);
313                 if (ret)
314                         goto err;
315         } else {
316                 bch2_inode_nlink_dec(trans, inode_u);
317         }
318
319         if (inode_u->bi_dir             == dirent_iter.pos.inode &&
320             inode_u->bi_dir_offset      == dirent_iter.pos.offset) {
321                 inode_u->bi_dir         = 0;
322                 inode_u->bi_dir_offset  = 0;
323         }
324
325         dir_u->bi_mtime = dir_u->bi_ctime = inode_u->bi_ctime = now;
326         dir_u->bi_nlink -= is_subdir_for_nlink(inode_u);
327         dir_u->bi_size  -= dirent_occupied_size(name);
328
329         ret =   bch2_hash_delete_at(trans, bch2_dirent_hash_desc,
330                                     &dir_hash, &dirent_iter,
331                                     BTREE_UPDATE_internal_snapshot_node) ?:
332                 bch2_inode_write(trans, &dir_iter, dir_u) ?:
333                 bch2_inode_write(trans, &inode_iter, inode_u);
334 err:
335         bch2_trans_iter_exit(trans, &inode_iter);
336         bch2_trans_iter_exit(trans, &dirent_iter);
337         bch2_trans_iter_exit(trans, &dir_iter);
338         return ret;
339 }
340
341 bool bch2_reinherit_attrs(struct bch_inode_unpacked *dst_u,
342                           struct bch_inode_unpacked *src_u)
343 {
344         u64 src, dst;
345         unsigned id;
346         bool ret = false;
347
348         for (id = 0; id < Inode_opt_nr; id++) {
349                 /* Skip attributes that were explicitly set on this inode */
350                 if (dst_u->bi_fields_set & (1 << id))
351                         continue;
352
353                 src = bch2_inode_opt_get(src_u, id);
354                 dst = bch2_inode_opt_get(dst_u, id);
355
356                 if (src == dst)
357                         continue;
358
359                 bch2_inode_opt_set(dst_u, id, src);
360                 ret = true;
361         }
362
363         return ret;
364 }
365
366 static int subvol_update_parent(struct btree_trans *trans, u32 subvol, u32 new_parent)
367 {
368         struct btree_iter iter;
369         struct bkey_i_subvolume *s =
370                 bch2_bkey_get_mut_typed(trans, &iter,
371                         BTREE_ID_subvolumes, POS(0, subvol),
372                         BTREE_ITER_cached, subvolume);
373         int ret = PTR_ERR_OR_ZERO(s);
374         if (ret)
375                 return ret;
376
377         s->v.fs_path_parent = cpu_to_le32(new_parent);
378         bch2_trans_iter_exit(trans, &iter);
379         return 0;
380 }
381
382 int bch2_rename_trans(struct btree_trans *trans,
383                       subvol_inum src_dir, struct bch_inode_unpacked *src_dir_u,
384                       subvol_inum dst_dir, struct bch_inode_unpacked *dst_dir_u,
385                       struct bch_inode_unpacked *src_inode_u,
386                       struct bch_inode_unpacked *dst_inode_u,
387                       const struct qstr *src_name,
388                       const struct qstr *dst_name,
389                       enum bch_rename_mode mode)
390 {
391         struct bch_fs *c = trans->c;
392         struct btree_iter src_dir_iter = { NULL };
393         struct btree_iter dst_dir_iter = { NULL };
394         struct btree_iter src_inode_iter = { NULL };
395         struct btree_iter dst_inode_iter = { NULL };
396         struct bch_hash_info src_hash, dst_hash;
397         subvol_inum src_inum, dst_inum;
398         u64 src_offset, dst_offset;
399         u64 now = bch2_current_time(c);
400         int ret;
401
402         ret = bch2_inode_peek(trans, &src_dir_iter, src_dir_u, src_dir,
403                               BTREE_ITER_intent);
404         if (ret)
405                 goto err;
406
407         src_hash = bch2_hash_info_init(c, src_dir_u);
408
409         if (dst_dir.inum        != src_dir.inum ||
410             dst_dir.subvol      != src_dir.subvol) {
411                 ret = bch2_inode_peek(trans, &dst_dir_iter, dst_dir_u, dst_dir,
412                                       BTREE_ITER_intent);
413                 if (ret)
414                         goto err;
415
416                 dst_hash = bch2_hash_info_init(c, dst_dir_u);
417         } else {
418                 dst_dir_u = src_dir_u;
419                 dst_hash = src_hash;
420         }
421
422         ret = bch2_dirent_rename(trans,
423                                  src_dir, &src_hash,
424                                  dst_dir, &dst_hash,
425                                  src_name, &src_inum, &src_offset,
426                                  dst_name, &dst_inum, &dst_offset,
427                                  mode);
428         if (ret)
429                 goto err;
430
431         ret = bch2_inode_peek(trans, &src_inode_iter, src_inode_u, src_inum,
432                               BTREE_ITER_intent);
433         if (ret)
434                 goto err;
435
436         if (dst_inum.inum) {
437                 ret = bch2_inode_peek(trans, &dst_inode_iter, dst_inode_u, dst_inum,
438                                       BTREE_ITER_intent);
439                 if (ret)
440                         goto err;
441         }
442
443         if (src_inode_u->bi_subvol &&
444             dst_dir.subvol != src_inode_u->bi_parent_subvol) {
445                 ret = subvol_update_parent(trans, src_inode_u->bi_subvol, dst_dir.subvol);
446                 if (ret)
447                         goto err;
448         }
449
450         if (mode == BCH_RENAME_EXCHANGE &&
451             dst_inode_u->bi_subvol &&
452             src_dir.subvol != dst_inode_u->bi_parent_subvol) {
453                 ret = subvol_update_parent(trans, dst_inode_u->bi_subvol, src_dir.subvol);
454                 if (ret)
455                         goto err;
456         }
457
458         /* Can't move across subvolumes, unless it's a subvolume root: */
459         if (src_dir.subvol != dst_dir.subvol &&
460             (!src_inode_u->bi_subvol ||
461              (dst_inum.inum && !dst_inode_u->bi_subvol))) {
462                 ret = -EXDEV;
463                 goto err;
464         }
465
466         if (mode == BCH_RENAME) {
467                 src_dir_u->bi_size -= dirent_occupied_size(src_name);
468                 dst_dir_u->bi_size += dirent_occupied_size(dst_name);
469         }
470
471         if (mode == BCH_RENAME_OVERWRITE)
472                 src_dir_u->bi_size -= dirent_occupied_size(src_name);
473
474         if (src_inode_u->bi_parent_subvol)
475                 src_inode_u->bi_parent_subvol = dst_dir.subvol;
476
477         if ((mode == BCH_RENAME_EXCHANGE) &&
478             dst_inode_u->bi_parent_subvol)
479                 dst_inode_u->bi_parent_subvol = src_dir.subvol;
480
481         src_inode_u->bi_dir             = dst_dir_u->bi_inum;
482         src_inode_u->bi_dir_offset      = dst_offset;
483
484         if (mode == BCH_RENAME_EXCHANGE) {
485                 dst_inode_u->bi_dir             = src_dir_u->bi_inum;
486                 dst_inode_u->bi_dir_offset      = src_offset;
487         }
488
489         if (mode == BCH_RENAME_OVERWRITE &&
490             dst_inode_u->bi_dir         == dst_dir_u->bi_inum &&
491             dst_inode_u->bi_dir_offset  == src_offset) {
492                 dst_inode_u->bi_dir             = 0;
493                 dst_inode_u->bi_dir_offset      = 0;
494         }
495
496         if (mode == BCH_RENAME_OVERWRITE) {
497                 if (S_ISDIR(src_inode_u->bi_mode) !=
498                     S_ISDIR(dst_inode_u->bi_mode)) {
499                         ret = -ENOTDIR;
500                         goto err;
501                 }
502
503                 if (S_ISDIR(dst_inode_u->bi_mode)) {
504                         ret = bch2_empty_dir_trans(trans, dst_inum);
505                         if (ret)
506                                 goto err;
507                 }
508         }
509
510         if (bch2_reinherit_attrs(src_inode_u, dst_dir_u) &&
511             S_ISDIR(src_inode_u->bi_mode)) {
512                 ret = -EXDEV;
513                 goto err;
514         }
515
516         if (mode == BCH_RENAME_EXCHANGE &&
517             bch2_reinherit_attrs(dst_inode_u, src_dir_u) &&
518             S_ISDIR(dst_inode_u->bi_mode)) {
519                 ret = -EXDEV;
520                 goto err;
521         }
522
523         if (is_subdir_for_nlink(src_inode_u)) {
524                 src_dir_u->bi_nlink--;
525                 dst_dir_u->bi_nlink++;
526         }
527
528         if (S_ISDIR(src_inode_u->bi_mode) &&
529             !src_inode_u->bi_subvol)
530                 src_inode_u->bi_depth = dst_dir_u->bi_depth + 1;
531
532         if (mode == BCH_RENAME_EXCHANGE &&
533             S_ISDIR(dst_inode_u->bi_mode) &&
534             !dst_inode_u->bi_subvol)
535                 dst_inode_u->bi_depth = src_dir_u->bi_depth + 1;
536
537         if (dst_inum.inum && is_subdir_for_nlink(dst_inode_u)) {
538                 dst_dir_u->bi_nlink--;
539                 src_dir_u->bi_nlink += mode == BCH_RENAME_EXCHANGE;
540         }
541
542         if (mode == BCH_RENAME_OVERWRITE)
543                 bch2_inode_nlink_dec(trans, dst_inode_u);
544
545         src_dir_u->bi_mtime             = now;
546         src_dir_u->bi_ctime             = now;
547
548         if (src_dir.inum != dst_dir.inum) {
549                 dst_dir_u->bi_mtime     = now;
550                 dst_dir_u->bi_ctime     = now;
551         }
552
553         src_inode_u->bi_ctime           = now;
554
555         if (dst_inum.inum)
556                 dst_inode_u->bi_ctime   = now;
557
558         ret =   bch2_inode_write(trans, &src_dir_iter, src_dir_u) ?:
559                 (src_dir.inum != dst_dir.inum
560                  ? bch2_inode_write(trans, &dst_dir_iter, dst_dir_u)
561                  : 0) ?:
562                 bch2_inode_write(trans, &src_inode_iter, src_inode_u) ?:
563                 (dst_inum.inum
564                  ? bch2_inode_write(trans, &dst_inode_iter, dst_inode_u)
565                  : 0);
566 err:
567         bch2_trans_iter_exit(trans, &dst_inode_iter);
568         bch2_trans_iter_exit(trans, &src_inode_iter);
569         bch2_trans_iter_exit(trans, &dst_dir_iter);
570         bch2_trans_iter_exit(trans, &src_dir_iter);
571         return ret;
572 }
573
574 static inline void prt_bytes_reversed(struct printbuf *out, const void *b, unsigned n)
575 {
576         bch2_printbuf_make_room(out, n);
577
578         unsigned can_print = min(n, printbuf_remaining(out));
579
580         b += n;
581
582         for (unsigned i = 0; i < can_print; i++)
583                 out->buf[out->pos++] = *((char *) --b);
584
585         printbuf_nul_terminate(out);
586 }
587
588 static inline void prt_str_reversed(struct printbuf *out, const char *s)
589 {
590         prt_bytes_reversed(out, s, strlen(s));
591 }
592
593 static inline void reverse_bytes(void *b, size_t n)
594 {
595         char *e = b + n, *s = b;
596
597         while (s < e) {
598                 --e;
599                 swap(*s, *e);
600                 s++;
601         }
602 }
603
604 /* XXX: we don't yet attempt to print paths when we don't know the subvol */
605 int bch2_inum_to_path(struct btree_trans *trans, subvol_inum inum, struct printbuf *path)
606 {
607         unsigned orig_pos = path->pos;
608         int ret = 0;
609
610         while (!(inum.subvol == BCACHEFS_ROOT_SUBVOL &&
611                  inum.inum   == BCACHEFS_ROOT_INO)) {
612                 struct bch_inode_unpacked inode;
613                 ret = bch2_inode_find_by_inum_trans(trans, inum, &inode);
614                 if (ret)
615                         goto disconnected;
616
617                 if (!inode.bi_dir && !inode.bi_dir_offset) {
618                         ret = -BCH_ERR_ENOENT_inode_no_backpointer;
619                         goto disconnected;
620                 }
621
622                 inum.subvol     = inode.bi_parent_subvol ?: inum.subvol;
623                 inum.inum       = inode.bi_dir;
624
625                 u32 snapshot;
626                 ret = bch2_subvolume_get_snapshot(trans, inum.subvol, &snapshot);
627                 if (ret)
628                         goto disconnected;
629
630                 struct btree_iter d_iter;
631                 struct bkey_s_c_dirent d = bch2_bkey_get_iter_typed(trans, &d_iter,
632                                 BTREE_ID_dirents, SPOS(inode.bi_dir, inode.bi_dir_offset, snapshot),
633                                 0, dirent);
634                 ret = bkey_err(d.s_c);
635                 if (ret)
636                         goto disconnected;
637
638                 struct qstr dirent_name = bch2_dirent_get_name(d);
639                 prt_bytes_reversed(path, dirent_name.name, dirent_name.len);
640
641                 prt_char(path, '/');
642
643                 bch2_trans_iter_exit(trans, &d_iter);
644         }
645
646         if (orig_pos == path->pos)
647                 prt_char(path, '/');
648 out:
649         ret = path->allocation_failure ? -ENOMEM : 0;
650         if (ret)
651                 goto err;
652
653         reverse_bytes(path->buf + orig_pos, path->pos - orig_pos);
654         return 0;
655 err:
656         return ret;
657 disconnected:
658         if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
659                 goto err;
660
661         prt_str_reversed(path, "(disconnected)");
662         goto out;
663 }
This page took 0.071573 seconds and 4 git commands to generate.