All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [bug report] ocfs2/cluster: Pin/unpin o2hb regions
@ 2022-01-19 11:29 Dan Carpenter via Ocfs2-devel
  2022-01-20  2:13 ` Joseph Qi via Ocfs2-devel
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter via Ocfs2-devel @ 2022-01-19 11:29 UTC (permalink / raw)
  To: ocfs2-devel

Hello OCFS2 developers,

The patch 58a3158a5d17: "ocfs2/cluster: Pin/unpin o2hb regions" from
Dec 14, 2010, leads to the following Smatch static checker warning:

	./include/linux/fs.h:777 inode_lock()
	warn: sleeping in atomic context

The call tree is:

o2hb_heartbeat_group_drop_item() <- disables preempt
o2hb_region_inc_user() <- disables preempt
-> o2hb_region_pin()
   -> o2nm_depend_item()
      -> configfs_depend_item()
         -> inode_lock()

fs/ocfs2/cluster/heartbeat.c
  2265        static int o2hb_region_pin(const char *region_uuid)
  2266        {
  2267                int ret = 0, found = 0;
  2268                struct o2hb_region *reg;
  2269                char *uuid;
  2270
  2271                assert_spin_locked(&o2hb_live_lock);
                      ^^^^^^^^^^^^^^^^^^

This code is holding a spin lock.

  2272
  2273                list_for_each_entry(reg, &o2hb_all_regions, hr_all_item) {
  2274                        if (reg->hr_item_dropped)
  2275                                continue;
  2276
  2277                        uuid = config_item_name(&reg->hr_item);
  2278
  2279                        /* local heartbeat */
  2280                        if (region_uuid) {
  2281                                if (strcmp(region_uuid, uuid))
  2282                                        continue;
  2283                                found = 1;
  2284                        }
  2285
  2286                        if (reg->hr_item_pinned || reg->hr_item_dropped)
  2287                                goto skip_pin;
  2288
  2289                        /* Ignore ENOENT only for local hb (userdlm domain) */
  2290                        ret = o2nm_depend_item(&reg->hr_item);
                                    ^^^^^^^^^^^^^^^^
The o2nm_depend_item() fucntion cannot succeed without taking a mutex.

  2291                        if (!ret) {
  2292                                mlog(ML_CLUSTER, "Pin region %s\n", uuid);
  2293                                reg->hr_item_pinned = 1;
  2294                        } else {
  2295                                if (ret == -ENOENT && found)
  2296                                        ret = 0;
  2297                                else {
  2298                                        mlog(ML_ERROR, "Pin region %s fails with %d\n",
  2299                                             uuid, ret);
  2300                                        break;
  2301                                }
  2302                        }
  2303        skip_pin:
  2304                        if (found)
  2305                                break;
  2306                }
  2307
  2308                return ret;
  2309        }

regards,
dan carpenter

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [Ocfs2-devel] [bug report] ocfs2/cluster: Pin/unpin o2hb regions
@ 2023-06-06  8:22 Dan Carpenter via Ocfs2-devel
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter via Ocfs2-devel @ 2023-06-06  8:22 UTC (permalink / raw)
  To: ocfs2-devel

[ This is ancient code. - dan ]

fs/fs_context.c
    168 {
    169         int ret;
    170 
    171         struct fs_parameter param = {
    172                 .key        = key,
    173                 .type        = fs_value_is_flag,
    174                 .size        = v_size,
    175         };
    176 
    177         if (value) {
--> 178                 param.string = kmemdup_nul(value, v_size, GFP_KERNEL);
                                                                  ^^^^^^^^^^
Sleeping

    179                 if (!param.string)
    180                         return -ENOMEM;
    181                 param.type = fs_value_is_string;
    182         }
    183 
    184         ret = vfs_parse_fs_param(fc, &param);
    185         kfree(param.string);
    186         return ret;
    187 }


There are a couple OCFS functions which call this sleeping function
while holding a spinlock.

o2hb_heartbeat_group_drop_item() <- disables preempt
o2hb_region_inc_user() <- disables preempt
-> o2hb_region_pin()
   -> o2nm_depend_item()
      -> configfs_depend_item()
         -> configfs_pin_fs()
            -> simple_pin_fs()
               -> vfs_kern_mount()
                  -> vfs_parse_fs_string()


fs/ocfs2/cluster/heartbeat.c
  2338  static int o2hb_region_inc_user(const char *region_uuid)
  2339  {
  2340          int ret = 0;
  2341  
  2342          spin_lock(&o2hb_live_lock);

Lock.

  2343  
  2344          /* local heartbeat */
  2345          if (!o2hb_global_heartbeat_active()) {
  2346              ret = o2hb_region_pin(region_uuid);

This function starts the call tree to vfs_parse_fs_string().

  2347              goto unlock;
  2348          }
  2349  

regards,
dan carpenter

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-06 13:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-19 11:29 [Ocfs2-devel] [bug report] ocfs2/cluster: Pin/unpin o2hb regions Dan Carpenter via Ocfs2-devel
2022-01-20  2:13 ` Joseph Qi via Ocfs2-devel
  -- strict thread matches above, loose matches on Subject: below --
2023-06-06  8:22 Dan Carpenter via Ocfs2-devel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.