Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typo in nocow option description #674

Open
wants to merge 149 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
8025220
bcachefs: don't free error pointers
May 3, 2024
6f590fd
bcachefs: bucket_pos_to_bp_noerror()
May 3, 2024
08e0398
bcachefs: Fix early error path in bch2_fs_btree_key_cache_exit()
May 3, 2024
708add4
bcachefs: Inodes need extra padding for varint_decode_fast()
May 3, 2024
7690610
bcachefs: Fix refcount put in sb_field_resize error path
May 3, 2024
d6caa8d
bcachefs: Initialize bch_write_op->failed in inline data path
May 4, 2024
c6cf85a
bcachefs: Fix bch2_dev_lookup() refcounting
May 4, 2024
9724f28
bcachefs: Fix lifetime issue in device iterator helpers
May 4, 2024
8e9c9bf
bcachefs: Add a better limit for maximum number of buckets
May 4, 2024
f8bfe8e
bcachefs: fix overflow in fiemap
reedriley May 4, 2024
d95aa33
bcachefs: Better write_super() error messages
May 3, 2024
6e1f310
bcachefs: Run upgrade/downgrade even in -o nochanges mode
Apr 29, 2024
a3d848a
bcachefs: printbuf improvements
Apr 10, 2024
b6d9a34
bcachefs: printbufs: prt_printf() now handles \t\r\n
Apr 10, 2024
ec96c18
bcachefs: prt_printf() now respects \r\n\t
Apr 10, 2024
0e60bf5
bcachefs: bch2_btree_node_header_to_text()
Apr 10, 2024
77d2863
bcachefs: bch2_journal_keys_dump()
Apr 9, 2024
62f1dae
bcachefs: bch2_hash_lookup() now returns bkey_s_c
Apr 7, 2024
5cac5fb
bcachefs: add btree_node_merging_disabled debug param
Apr 5, 2024
6849246
bcachefs: bch2_btree_path_to_text()
Apr 6, 2024
06b8f60
bcachefs: New assertion for writing to the journal after shutdown
Feb 21, 2024
0969555
bcachefs: allow for custom action in fsck error messages
Mar 28, 2024
2b086f7
bcachefs: Don't read journal just for fsck
Mar 31, 2024
dabe606
bcachefs: When traversing to interior nodes, propagate result to path…
Mar 22, 2024
395a37a
bcachefs: Optimize eytzinger0_sort() with bottom-up heapsort
visitorckw Apr 7, 2024
36d144c
bcachefs: kill for_each_btree_key_old()
Apr 6, 2024
35fab09
bcachefs: for_each_btree_key_continue()
Apr 7, 2024
b51e214
bcachefs: bch2_gc() is now private to btree_gc.c
Apr 6, 2024
6321082
bcachefs: Finish converting reconstruct_alloc to errors_silent
Apr 7, 2024
9a6373a
bcachefs: kill metadata only gc
Apr 7, 2024
bd681e4
bcachefs: move topology repair kick to gc_btrees()
Apr 7, 2024
e88ad2c
bcachefs: move root node topo checks to node_check_topology()
Apr 7, 2024
be3d7da
bcachefs: gc_btree_init_recurse() uses gc_mark_node()
Apr 7, 2024
86b20b2
bcachefs: mark_superblock cleanup
Apr 7, 2024
e843546
bcachefs: __BTREE_ITER_ALL_SNAPSHOTS -> BTREE_ITER_SNAPSHOT_FIELD
Apr 7, 2024
8107a57
bcachefs: iter/update/trigger/str_hash flag cleanup
Apr 7, 2024
79f6b82
bcachefs: bch2_btree_insert_trans() no longer specifies BTREE_ITER_ca…
Apr 7, 2024
6065f93
bcachefs: bch2_dir_emit() - drop_locks_do() conversion
Apr 10, 2024
a3ad294
bcachefs: bch2_trans_relock_fail() - factor out slowpath
Apr 9, 2024
bff9f77
bcachefs: bucket_valid()
Apr 12, 2024
76212c7
bcachefs: member helper cleanups
Apr 12, 2024
5901e14
bcachefs: chardev: make bch_chardev_class constant
rbmarliere Mar 8, 2024
83b378e
bcachefs: fix typo in reference to BCACHEFS_DEBUG
Apr 11, 2024
c5e5ccd
bcachefs: get_unlocked_mut_path -> bch2_path_get_unlocked_mut
Apr 12, 2024
61fdc4c
bcachefs: prefer drop_locks_do()
Apr 13, 2024
f3074e4
bcachefs: bch2_trans_commit_flags_to_text()
Apr 13, 2024
4f33531
bcachefs: maintain lock invariants in btree_iter_next_node()
Apr 11, 2024
8d32a9e
bcachefs: bch2_btree_path_upgrade() checks nodes_locked, not uptodate
Apr 11, 2024
ce5b96d
bcachefs: Use bch2_btree_path_upgrade() in key cache traverse
Apr 10, 2024
6cf4b01
bcachefs: bch2_trans_unlock() must always be followed by relock() or …
Apr 10, 2024
3c0d1e7
bcachefs: bch2_btree_root_alloc_fake_trans()
Apr 14, 2024
d656e43
bcachefs: trans->locked
Apr 9, 2024
af725fb
bcachefs: bch2_btree_path_can_relock()
Apr 11, 2024
ea00a54
bcachefs: bch2_trans_verify_not_unlocked()
Apr 10, 2024
6456967
bcachefs: assert that online_reserved == 0 on shutdown
Apr 14, 2024
d3a8326
bcachefs: fs_alloc_debug_to_text()
Apr 16, 2024
7692189
bcachefs: Add asserts to bch2_dev_btree_bitmap_marked_sectors()
Apr 16, 2024
07a8e79
bcachefs: Check for writing btree_ptr_v2.sectors_written == 0
Apr 16, 2024
0178420
bcachefs: Rip bch2_snapshot_equiv() out of fsck
Apr 17, 2024
718f50a
bcachefs: make btree read errors silent during scan
Apr 17, 2024
23c5d06
bcachefs: Sync journal when we complete a recovery pass
Apr 17, 2024
6f59c64
bcachefs: fix flag printing in journal_buf_to_text()
Apr 20, 2024
7ae1453
bcachefs: Move gc of bucket.oldest_gen to workqueue
Apr 20, 2024
bf5d4d4
bcachefs: Remove calls to folio_set_error
Apr 20, 2024
73b1298
bcachefs: Btree key cache instrumentation
Apr 20, 2024
e81bbf1
bcachefs: Add btree_allocated_bitmap to member_to_text()
Apr 20, 2024
64dc0e7
bcachefs: plumb data_type into bch2_bucket_alloc_trans()
Apr 20, 2024
f12200a
bcachefs: journal seq blacklist gc no longer has to walk btree
Apr 21, 2024
71ba41a
bcachefs: Clean up inode alloc
Apr 21, 2024
df71e5e
bcachefs: bucket_data_type_mismatch()
Apr 22, 2024
5d55dca
bcachefs: mark_stripe_bucket cleanup
Apr 20, 2024
0e448c5
bcachefs: Consolidate mark_stripe_bucket() and trans_mark_stripe_buck…
Apr 22, 2024
6794fd0
bcachefs: bch2_bucket_ref_update()
Apr 19, 2024
4623d80
bcachefs: kill gc looping for bucket gens
Apr 17, 2024
6ebaeb6
bcachefs: Run bch2_check_fix_ptrs() via triggers
Apr 7, 2024
1377de7
bcachefs: do reflink_p repair from BTREE_TRIGGER_check_repair
Apr 7, 2024
ca12fb1
bcachefs: Kill gc_init_recurse()
Apr 7, 2024
e32cfa5
bcachefs: Fix type of flags parameter for some ->trigger() implementa…
nathanchance Apr 23, 2024
0899ad6
bcachefs: Fix format specifiers in bch2_btree_key_cache_to_text()
nathanchance Apr 23, 2024
28b4c8f
bcachefs: fix btree_path_clone() ip_allocated
Apr 25, 2024
60c5c2b
bcachefs: eliminate the uninitialized compilation warning in bch2_rec…
Apr 26, 2024
f1bada9
bcachefs: uninline set_btree_iter_dontneed()
Apr 25, 2024
bf323e4
bcachefs: bch_member.last_journal_bucket
Apr 26, 2024
4fb46ee
bcachefs: check for inodes that should have backpointers in fsck
Apr 26, 2024
66245f9
bcachefs: check inode backpointer in bch2_lookup()
Apr 25, 2024
19b5ff9
bcachefs: Simplify resuming of journal position
Apr 26, 2024
9326a32
bcachefs: Change destroy_inode to free_inode
Apr 26, 2024
ef76eea
bcachefs: Fix error path of bch2_link_trans()
Apr 30, 2024
7d34a63
bcachefs: Correct the FS_IOC_GETFLAGS to FS_IOC32_GETFLAGS in bch2_co…
Apr 30, 2024
3f48490
bcachefs: delete old gen check bch2_alloc_write_key()
Apr 30, 2024
47cfce5
bcachefs: dirty_sectors -> replicas_sectors
Apr 30, 2024
3edbeb4
bcachefs: alloc_data_type_set()
Apr 30, 2024
07d4ae0
bcachefs: kill bch2_dev_usage_update_m()
Apr 30, 2024
9eddf76
bcachefs: __mark_pointer now takes bch_alloc_v4
Apr 30, 2024
301de42
bcachefs: __mark_stripe_bucket() now takes bch_alloc_v4
Apr 30, 2024
082d729
bcachefs: simplify bch2_trans_start_alloc_update()
Apr 30, 2024
79bcda9
bcachefs: CodingStyle
Apr 29, 2024
c72d28e
bcachefs: Kill opts.buckets_nouse
Apr 6, 2024
5746c2c
bcachefs: On device add, prefer unused slots
Apr 30, 2024
2817919
bcachefs: x-macroize journal flags enums
Apr 30, 2024
b20eab5
bcachefs: bch2_bkey_drop_ptrs() declares loop iter
May 1, 2024
bda02c0
closures: closure_sync_timeout()
May 3, 2024
e6c9572
bcachefs: bch2_print_allocator_stuck()
May 3, 2024
1eaf11c
bcachefs: New helpers for device refcounts
May 3, 2024
f8e1117
bcachefs: Debug asserts for ca->ref
May 3, 2024
0e0b1ad
bcachefs: bch2_dev_safe() -> bch2_dev_rcu()
Apr 30, 2024
bd70102
bcachefs: Pass device to bch2_alloc_write_key()
Apr 30, 2024
70c951e
bcachefs: Pass device to bch2_bucket_do_index()
Apr 30, 2024
7f0c645
bcachefs: bch2_dev_btree_bitmap_marked() -> bch2_dev_rcu()
Apr 30, 2024
e4a30ba
bcachefs: journal_replay_entry_early() checks for nonexistent device
Apr 30, 2024
04ca18b
bcachefs: bch2_have_enough_devs() checks for nonexistent device
Apr 30, 2024
43636d7
bcachefs: bch2_dev_tryget()
Apr 30, 2024
e4da7ab
bcachefs: Convert to bch2_dev_tryget_noerror()
May 3, 2024
edcbbf2
bcachefs: bch2_check_alloc_key() -> bch2_dev_tryget_noerror()
Apr 30, 2024
78974cc
bcachefs: bch2_trigger_alloc() -> bch2_dev_tryget()
Apr 30, 2024
292b167
bcachefs: bch2_bucket_ref_update() now takes bch_dev
Apr 30, 2024
fe15c51
bcachefs: bch2_evacuate_bucket() -> bch2_dev_tryget()
Apr 30, 2024
7366034
bcachefs: bch2_dev_iterate()
Apr 30, 2024
33364f9
bcachefs: PTR_BUCKET_POS() now takes bch_dev
Apr 30, 2024
d2cc89a
bcachefs: Kill bch2_dev_bkey_exists() in backpointer code
Apr 30, 2024
8b44698
bcachefs: move replica_set from bch_dev to bch_fs
May 1, 2024
7114a49
bcachefs: ob_dev()
May 1, 2024
288e4a0
bcachefs: ec_validate_checksums() -> bch2_dev_tryget()
May 1, 2024
2f0fe17
bcachefs: bch2_extent_merge() -> bch2_dev_rcu()
May 1, 2024
d662676
bcachefs: extent_ptr_durability() -> bch2_dev_rcu()
May 1, 2024
6b3ad4d
bcachefs: ptr_stale() -> dev_ptr_stale()
May 1, 2024
aa7ed75
bcachefs: extent_ptr_invalid() -> bch2_dev_rcu()
May 1, 2024
3a07661
bcachefs: bch2_bkey_has_target() -> bch2_dev_rcu()
May 1, 2024
272144d
bcachefs: bch2_extent_normalize() -> bch2_dev_rcu()
May 1, 2024
a884326
bcachefs: kill bch2_dev_bkey_exists() in btree_gc.c
May 1, 2024
62eaacc
bcachefs: bch2_dev_bucket_exists() uses bch2_dev_rcu()
May 1, 2024
0501211
bcachefs: pass bch_dev to read_from_stale_dirty_pointer()
May 1, 2024
01db4cf
bcachefs: kill bch2_dev_bkey_exists() in bkey_pick_read_device()
May 1, 2024
7c344fa
bcachefs: kill bch2_dev_bkey_exists() in data_update_init()
May 1, 2024
e6d02eb
bcachefs: bch2_dev_have_ref()
May 1, 2024
ccf92fa
bcachefs: kill bch2_dev_bkey_exists() in check_alloc_info()
May 1, 2024
8a718a2
bcachefs: kill bch2_dev_bkey_exists() in discard_one_bucket_fast()
May 1, 2024
ac36224
bcachefs: kill bch2_dev_bkey_exists() in journal_ptrs_to_text()
May 1, 2024
bab182c
bcachefs: Move nocow unlock to bch2_write_endio()
May 1, 2024
7a0963e
bcachefs: bch2_dev_get_ioref2(); alloc_background.c
May 3, 2024
6d3220d
bcachefs: bch2_dev_get_ioref2(); backpointers.c
May 3, 2024
7e0f626
bcachefs: bch2_dev_get_ioref2(); btree_io.c
May 3, 2024
b45ef18
bcachefs: bch2_dev_get_ioref2(); io_write.c
May 3, 2024
6144d47
bcachefs: bch2_dev_get_ioref2(); journal_io.c
May 3, 2024
b5074a2
bcachefs: bch2_dev_get_ioref2(); debug.c
May 3, 2024
7422974
fixup! bcachefs: bch2_print_allocator_stuck()
May 5, 2024
53d6369
bcachefs: Better bucket alloc tracepoints
May 4, 2024
9adaa88
bcachefs: Allocator prefers not to expand mi.btree_allocated bitmap
Apr 20, 2024
bc96dcc
Fix typo in nocow option description
matteopt May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 186 additions & 0 deletions Documentation/filesystems/bcachefs/CodingStyle.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
.. SPDX-License-Identifier: GPL-2.0

bcachefs coding style
=====================

Good development is like gardening, and codebases are our gardens. Tend to them
every day; look for little things that are out of place or in need of tidying.
A little weeding here and there goes a long way; don't wait until things have
spiraled out of control.

Things don't always have to be perfect - nitpicking often does more harm than
good. But appreciate beauty when you see it - and let people know.

The code that you are afraid to touch is the code most in need of refactoring.

A little organizing here and there goes a long way.

Put real thought into how you organize things.

Good code is readable code, where the structure is simple and leaves nowhere
for bugs to hide.

Assertions are one of our most important tools for writing reliable code. If in
the course of writing a patchset you encounter a condition that shouldn't
happen (and will have unpredictable or undefined behaviour if it does), or
you're not sure if it can happen and not sure how to handle it yet - make it a
BUG_ON(). Don't leave undefined or unspecified behavior lurking in the codebase.

By the time you finish the patchset, you should understand better which
assertions need to be handled and turned into checks with error paths, and
which should be logically impossible. Leave the BUG_ON()s in for the ones which
are logically impossible. (Or, make them debug mode assertions if they're
expensive - but don't turn everything into a debug mode assertion, so that
we're not stuck debugging undefined behaviour should it turn out that you were
wrong).

Assertions are documentation that can't go out of date. Good assertions are
wonderful.

Good assertions drastically and dramatically reduce the amount of testing
required to shake out bugs.

Good assertions are based on state, not logic. To write good assertions, you
have to think about what the invariants on your state are.

Good invariants and assertions will hold everywhere in your codebase. This
means that you can run them in only a few places in the checked in version, but
should you need to debug something that caused the assertion to fail, you can
quickly shotgun them everywhere to find the codepath that broke the invariant.

A good assertion checks something that the compiler could check for us, and
elide - if we were working in a language with embedded correctness proofs that
the compiler could check. This is something that exists today, but it'll likely
still be a few decades before it comes to systems programming languages. But we
can still incorporate that kind of thinking into our code and document the
invariants with runtime checks - much like the way people working in
dynamically typed languages may add type annotations, gradually making their
code statically typed.

Looking for ways to make your assertions simpler - and higher level - will
often nudge you towards making the entire system simpler and more robust.

Good code is code where you can poke around and see what it's doing -
introspection. We can't debug anything if we can't see what's going on.

Whenever we're debugging, and the solution isn't immediately obvious, if the
issue is that we don't know where the issue is because we can't see what's
going on - fix that first.

We have the tools to make anything visible at runtime, efficiently - RCU and
percpu data structures among them. Don't let things stay hidden.

The most important tool for introspection is the humble pretty printer - in
bcachefs, this means `*_to_text()` functions, which output to printbufs.

Pretty printers are wonderful, because they compose and you can use them
everywhere. Having functions to print whatever object you're working with will
make your error messages much easier to write (therefore they will actually
exist) and much more informative. And they can be used from sysfs/debugfs, as
well as tracepoints.

Runtime info and debugging tools should come with clear descriptions and
labels, and good structure - we don't want files with a list of bare integers,
like in procfs. Part of the job of the debugging tools is to educate users and
new developers as to how the system works.

Error messages should, whenever possible, tell you everything you need to debug
the issue. It's worth putting effort into them.

Tracepoints shouldn't be the first thing you reach for. They're an important
tool, but always look for more immediate ways to make things visible. When we
have to rely on tracing, we have to know which tracepoints we're looking for,
and then we have to run the troublesome workload, and then we have to sift
through logs. This is a lot of steps to go through when a user is hitting
something, and if it's intermittent it may not even be possible.

The humble counter is an incredibly useful tool. They're cheap and simple to
use, and many complicated internal operations with lots of things that can
behave weirdly (anything involving memory reclaim, for example) become
shockingly easy to debug once you have counters on every distinct codepath.

Persistent counters are even better.

When debugging, try to get the most out of every bug you come across; don't
rush to fix the initial issue. Look for things that will make related bugs
easier the next time around - introspection, new assertions, better error
messages, new debug tools, and do those first. Look for ways to make the system
better behaved; often one bug will uncover several other bugs through
downstream effects.

Fix all that first, and then the original bug last - even if that means keeping
a user waiting. They'll thank you in the long run, and when they understand
what you're doing you'll be amazed at how patient they're happy to be. Users
like to help - otherwise they wouldn't be reporting the bug in the first place.

Talk to your users. Don't isolate yourself.

Users notice all sorts of interesting things, and by just talking to them and
interacting with them you can benefit from their experience.

Spend time doing support and helpdesk stuff. Don't just write code - code isn't
finished until it's being used trouble free.

This will also motivate you to make your debugging tools as good as possible,
and perhaps even your documentation, too. Like anything else in life, the more
time you spend at it the better you'll get, and you the developer are the
person most able to improve the tools to make debugging quick and easy.

Be wary of how you take on and commit to big projects. Don't let development
become product-manager focused. Often time an idea is a good one but needs to
wait for its proper time - but you won't know if it's the proper time for an
idea until you start writing code.

Expect to throw a lot of things away, or leave them half finished for later.
Nobody writes all perfect code that all gets shipped, and you'll be much more
productive in the long run if you notice this early and shift to something
else. The experience gained and lessons learned will be valuable for all the
other work you do.

But don't be afraid to tackle projects that require significant rework of
existing code. Sometimes these can be the best projects, because they can lead
us to make existing code more general, more flexible, more multipurpose and
perhaps more robust. Just don't hesitate to abandon the idea if it looks like
it's going to make a mess of things.

Complicated features can often be done as a series of refactorings, with the
final change that actually implements the feature as a quite small patch at the
end. It's wonderful when this happens, especially when those refactorings are
things that improve the codebase in their own right. When that happens there's
much less risk of wasted effort if the feature you were going for doesn't work
out.

Always strive to work incrementally. Always strive to turn the big projects
into little bite sized projects that can prove their own merits.

Instead of always tackling those big projects, look for little things that
will be useful, and make the big projects easier.

The question of what's likely to be useful is where junior developers most
often go astray - doing something because it seems like it'll be useful often
leads to overengineering. Knowing what's useful comes from many years of
experience, or talking with people who have that experience - or from simply
reading lots of code and looking for common patterns and issues. Don't be
afraid to throw things away and do something simpler.

Talk about your ideas with your fellow developers; often times the best things
come from relaxed conversations where people aren't afraid to say "what if?".

Don't neglect your tools.

The most important tools (besides the compiler and our text editor) are the
tools we use for testing. The shortest possible edit/test/debug cycle is
essential for working productively. We learn, gain experience, and discover the
errors in our thinking by running our code and seeing what happens. If your
time is being wasted because your tools are bad or too slow - don't accept it,
fix it.

Put effort into your documentation, commmit messages, and code comments - but
don't go overboard. A good commit message is wonderful - but if the information
was important enough to go in a commit message, ask yourself if it would be
even better as a code comment.

A good code comment is wonderful, but even better is the comment that didn't
need to exist because the code was so straightforward as to be obvious;
organized into small clean and tidy modules, with clear and descriptive names
for functions and variable, where every line of code has a clear purpose.
1 change: 1 addition & 0 deletions Documentation/filesystems/bcachefs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ bcachefs Documentation
:maxdepth: 2
:numbered:

CodingStyle
errorcodes
41 changes: 13 additions & 28 deletions fs/bcachefs/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,12 @@ struct posix_acl *bch2_get_acl(struct mnt_idmap *idmap,
struct btree_trans *trans = bch2_trans_get(c);
struct btree_iter iter = { NULL };
struct posix_acl *acl = NULL;
struct bkey_s_c k;
int ret;
retry:
bch2_trans_begin(trans);

ret = bch2_hash_lookup(trans, &iter, bch2_xattr_hash_desc,
&hash, inode_inum(inode), &search, 0);
if (ret)
goto err;

k = bch2_btree_iter_peek_slot(&iter);
ret = bkey_err(k);
struct bkey_s_c k = bch2_hash_lookup(trans, &iter, bch2_xattr_hash_desc,
&hash, inode_inum(inode), &search, 0);
int ret = bkey_err(k);
if (ret)
goto err;

Expand Down Expand Up @@ -366,7 +360,7 @@ int bch2_set_acl(struct mnt_idmap *idmap,

ret = bch2_subvol_is_ro_trans(trans, inode->ei_subvol) ?:
bch2_inode_peek(trans, &inode_iter, &inode_u, inode_inum(inode),
BTREE_ITER_INTENT);
BTREE_ITER_intent);
if (ret)
goto btree_err;

Expand Down Expand Up @@ -414,39 +408,30 @@ int bch2_acl_chmod(struct btree_trans *trans, subvol_inum inum,
struct bch_hash_info hash_info = bch2_hash_info_init(trans->c, inode);
struct xattr_search_key search = X_SEARCH(KEY_TYPE_XATTR_INDEX_POSIX_ACL_ACCESS, "", 0);
struct btree_iter iter;
struct bkey_s_c_xattr xattr;
struct bkey_i_xattr *new;
struct posix_acl *acl = NULL;
struct bkey_s_c k;
int ret;

ret = bch2_hash_lookup(trans, &iter, bch2_xattr_hash_desc,
&hash_info, inum, &search, BTREE_ITER_INTENT);
struct bkey_s_c k = bch2_hash_lookup(trans, &iter, bch2_xattr_hash_desc,
&hash_info, inum, &search, BTREE_ITER_intent);
int ret = bkey_err(k);
if (ret)
return bch2_err_matches(ret, ENOENT) ? 0 : ret;

k = bch2_btree_iter_peek_slot(&iter);
ret = bkey_err(k);
if (ret)
goto err;
xattr = bkey_s_c_to_xattr(k);
struct bkey_s_c_xattr xattr = bkey_s_c_to_xattr(k);

acl = bch2_acl_from_disk(trans, xattr_val(xattr.v),
le16_to_cpu(xattr.v->x_val_len));
ret = PTR_ERR_OR_ZERO(acl);
if (IS_ERR_OR_NULL(acl))
if (ret)
goto err;

ret = allocate_dropping_locks_errcode(trans,
__posix_acl_chmod(&acl, _gfp, mode));
ret = allocate_dropping_locks_errcode(trans, __posix_acl_chmod(&acl, _gfp, mode));
if (ret)
goto err;

new = bch2_acl_to_xattr(trans, acl, ACL_TYPE_ACCESS);
if (IS_ERR(new)) {
ret = PTR_ERR(new);
struct bkey_i_xattr *new = bch2_acl_to_xattr(trans, acl, ACL_TYPE_ACCESS);
ret = PTR_ERR_OR_ZERO(new);
if (ret)
goto err;
}

new->k.p = iter.pos;
ret = bch2_trans_update(trans, &iter, &new->k_i, 0);
Expand Down
Loading