ocfs2/cluster: Pin/unpin o2hb regions
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(®->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(®->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
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
Hi Dan Carpenter,
Thanks for the reporting.
It seems the bug truly exists, but currently I don't have an easy way to fix it. I'll look it deeply later.
Thanks,
Joseph
Quoted 71 lines · On 1/19/22 7:29 PM, Dan Carpenter via Ocfs2-devel wrote:
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 contextThe call tree is:
o2hb_heartbeat_group_drop_item()<- disables preempto2hb_region_inc_user()<- disables preempt ->o2hb_region_pin()
->o2nm_depend_item()-> configfs_depend_item() -> inode_lock()
fs/ocfs2/cluster/heartbeat.c
2265 static into2hb_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
2273list_for_each_entry(reg, &o2hb_all_regions, hr_all_item){
2274 if (reg->hr_item_dropped)
2275 continue;
2276
2277 uuid =config_item_name(®->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 gotoskip_pin;
2288
2289 /* Ignore ENOENT only for local hb (userdlm domain) */2290 ret = o2nm_depend_item(®->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 }
Quoted 7 lines
regards,
dan carpenter_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel