On Fri, Sep 15, 2023 at 03:57:00PM +0300, Dan Carpenter wrote:
> Hello Kent Overstreet,
>
> The patch 46be00209417: "bcachefs: Rhashtable based buckets_in_flight
> for copygc" from Mar 11, 2023 (linux-next), leads to the following
> Smatch static checker warning:
>
> fs/bcachefs/movinggc.c:224 bch2_copygc()
> error: 'f' dereferencing possible ERR_PTR()
>
> fs/bcachefs/movinggc.c
> 190 noinline
> 191 static int bch2_copygc(struct btree_trans *trans,
> 192 struct moving_context *ctxt,
> 193 struct buckets_in_flight *buckets_in_flight)
> 194 {
> 195 struct bch_fs *c = trans->c;
> 196 struct data_update_opts data_opts = {
> 197 .btree_insert_flags = BCH_WATERMARK_copygc,
> 198 };
> 199 move_buckets buckets = { 0 };
> 200 struct move_bucket_in_flight *f;
> 201 struct move_bucket *i;
> 202 u64 moved = atomic64_read(&ctxt->stats->sectors_moved);
> 203 int ret = 0;
> 204
> 205 ret = bch2_copygc_get_buckets(trans, ctxt, buckets_in_flight,
> &buckets);
> 206 if (ret)
> 207 goto err;
> 208
> 209 darray_for_each(buckets, i) {
> 210 if (unlikely(freezing(current)))
> 211 break;
> 212
> 213 f = move_bucket_in_flight_add(buckets_in_flight, *i);
>
> move_bucket_in_flight_add() can return a mix of error codes such as
> -E2BIG.
E2BIG is not possible since we don't set max_elems when initializing the
rhashtable...