]> git.dujemihanovic.xyz Git - linux.git/commitdiff
bcachefs: Replace bare EEXIST with private error codes
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 27 May 2024 02:52:22 +0000 (22:52 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 21 Jun 2024 14:17:07 +0000 (10:17 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c
fs/bcachefs/errcode.h
fs/bcachefs/fs-ioctl.c
fs/bcachefs/str_hash.h
fs/bcachefs/super.c

index e5e7d33f4a5ef95033aa170e2d736fc19e5922d2..8dec2c6cbb7eb05c22a7ee543c007187aa070c2c 100644 (file)
@@ -1643,7 +1643,7 @@ static int discard_in_flight_add(struct bch_fs *c, struct bpos bucket)
        mutex_lock(&c->discard_buckets_in_flight_lock);
        darray_for_each(c->discard_buckets_in_flight, i)
                if (bkey_eq(*i, bucket)) {
-                       ret = -EEXIST;
+                       ret = -BCH_ERR_EEXIST_discard_in_flight_add;
                        goto out;
                }
 
index dbe35b80bc0b893cb2c914c699c14573966590e4..58612abf7927af920730fba98d685867411774fb 100644 (file)
        x(ENOENT,                       ENOENT_dev_idx_not_found)               \
        x(ENOTEMPTY,                    ENOTEMPTY_dir_not_empty)                \
        x(ENOTEMPTY,                    ENOTEMPTY_subvol_not_empty)             \
+       x(EEXIST,                       EEXIST_str_hash_set)                    \
+       x(EEXIST,                       EEXIST_discard_in_flight_add)           \
+       x(EEXIST,                       EEXIST_subvolume_create)                \
        x(0,                            open_buckets_empty)                     \
        x(0,                            freelist_empty)                         \
        x(BCH_ERR_freelist_empty,       no_buckets_found)                       \
index 3551a737181b2ef94ce344fb333d886df73e9a46..79a0c8732bced95d956dc93e719c5ca5ddeb3a2c 100644 (file)
@@ -373,7 +373,7 @@ retry:
        }
 
        if (dst_dentry->d_inode) {
-               error = -EEXIST;
+               error = -BCH_ERR_EEXIST_subvolume_create;
                goto err3;
        }
 
index cbad9b27874fed69d4f041fd76cd2225dfdce254..c8c266cb579726ee004ff67290ce61f0301869f1 100644 (file)
@@ -300,7 +300,7 @@ not_found:
        if (!found && (flags & STR_HASH_must_replace)) {
                ret = -BCH_ERR_ENOENT_str_hash_set_must_replace;
        } else if (found && (flags & STR_HASH_must_create)) {
-               ret = -EEXIST;
+               ret = -BCH_ERR_EEXIST_str_hash_set;
        } else {
                if (!found && slot.path)
                        swap(iter, slot);
index 635da5b3439cf2e90e8458ea6080dad6d36ad8b8..9083df82073a562344e01af41a04b41ec4177a27 100644 (file)
@@ -931,12 +931,13 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
        if (ret)
                goto err;
 
-       for (i = 0; i < c->sb.nr_devices; i++)
-               if (bch2_member_exists(c->disk_sb.sb, i) &&
-                   bch2_dev_alloc(c, i)) {
-                       ret = -EEXIST;
+       for (i = 0; i < c->sb.nr_devices; i++) {
+               if (!bch2_member_exists(c->disk_sb.sb, i))
+                       continue;
+               ret = bch2_dev_alloc(c, i);
+               if (ret)
                        goto err;
-               }
+       }
 
        bch2_journal_entry_res_resize(&c->journal,
                        &c->btree_root_journal_res,