OCFS2: allow the ocfs2 heartbeat thread to prioritize I/O --revision 3
PATCH 2/3 OCFS2: allow the ocfs2 heartbeat thread to prioritize I/O --revision 3
- replace calling syscall interface with running ionice
- fix the running ionice return code
- use device name instead of uuid for mount.ocfs2
zhen wei
[email protected]
+86 10 65339225
-------------- next part --------------
libocfs2/ocfs2_err.et +3 -0
@@ -159,4 +159,7 @@ ec OCFS2_ET_BLOCK_SIZE_TOO_SMALL_FOR_HAR ec OCFS2_ET_INVALID_LOCKRES, "The lock name is invalid" +ec OCFS2_ET_NO_IONICE, + "Can't find ionice" + end
libo2cb/include/o2cb.h +4 -0
@@ -98,6 +98,10 @@ errcode_t o2cb_start_heartbeat_region_peerrcode_t o2cb_stop_heartbeat_region_perm (const char *cluster_name,const char *region_name); +errcode_t o2cb_get_hb_thread_pid (const char *cluster_name, +const char *region_name, +pid_t *pid); +errcode_t o2cb_get_region_ref (const char *region_name,int undo); errcode_t o2cb_put_region_ref(const char *region_name,
libo2cb/o2cb_abi.c +30 -0
@@ -1257,6 +1257,36 @@ void o2cb_free_nodes_list(char **nodes)o2cb_free_dir_list (nodes); } +errcode_t o2cb_get_hb_thread_pid (const char *cluster_name,const char *region_name, +pid_t *pid) +{ +char attr_path[PATH_MAX ]; +char _fake_cluster_name[NAME_MAX ]; +char attr_value[16 ]; +errcode_t ret; + +if (!cluster_name) { + ret =_fake_default_cluster (_fake_cluster_name); +if (ret) +return ret; + cluster_name = _fake_cluster_name; + } + + ret =snprintf (attr_path,PATH_MAX -1 , +O2CB_FORMAT_HEARTBEAT_REGION_ATTR , + configfs_path, cluster_name, region_name, +"pid" ); + +if ((ret <=0 ) || (ret == (PATH_MAX -1 ))) +return O2CB_ET_INTERNAL_FAILURE ; + + ret =o2cb_get_attribute (attr_path, attr_value,sizeof (attr_value) -1 ); +if (ret ==0 ) + *pid =atoi (attr_value); + +return ret; +} +errcode_t o2cb_get_node_num (const char *cluster_name,const char *node_name,uint16_t *node_num) {
ocfs2_hb_ctl/ocfs2_hb_ctl.c +65 -2
133 lines not on this page · raw message
PATCH 2/3 OCFS2: allow the ocfs2 heartbeat thread to prioritize I/O --revision 3
Hi Zwei,
Quoted 3 lines · Zhen Wei
- replace calling syscall interface with running ionice
- fix the running ionice return code
- use device name instead of uuid for mount.ocfs2
The kernel patch and the mount.ocfs2 patches look good. I only have a couple of comments for this one below.
ocfs2_hb_ctl/ocfs2_hb_ctl.c static errcode_t start_heartbeat(struct · line 301
Quoted 11 lines
ocfs2_hb_ctl/ocfs2_hb_ctl.c +7
-0@@ -289,6 +292,41 @@ static errcode_t start_heartbeat(structreturn err; } +static errcode_t adjust_priority (struct hb_ctl_options *hbo) +{ +int ret, child_status; +pid_t hb_pid, child_pid; +char level_arg[16 ], pid_arg[16 ]; + +if (access ("/usr/bin/ionice" ,X_OK ) !=0 )
You might want to make "/usr/bin/ionice" a #define at the top of this file, since we use it at least twice.
ocfs2_hb_ctl/ocfs2_hb_ctl.c static errcode_t start_heartbeat(struct · line 304
Quoted 3 lines
ocfs2_hb_ctl/ocfs2_hb_ctl.c +3
-0+return OCFS2_ET_NO_IONICE ; + +get_uuid (hbo->dev_str, hbo->uuid_str);
You shouldn't have to call get_uuid() here -- see my comments below.
ocfs2_hb_ctl/ocfs2_hb_ctl.c static int process_options(struct hb_ctl · line 440
Quoted 10 lines
ocfs2_hb_ctl/ocfs2_hb_ctl.c +6
-0@@ -385,6 +432,13 @@ static int process_options(struct hb_ctl ret = -EINVAL ;break ; +case HB_ACTION_IONICE : +/* ionice needs uuid and priority */ +if (!hbo->dev_str || hbo->io_prio <0 || + hbo->io_prio >7 ) + ret = -EINVAL ; +break ;
The ionice option should be just like the other options and allow the user to specify an uuid _or_ a device. The main function will call get_uuid() if the device was specified.
This will also help avoid the manual call to get_uuid() you have up in adjust_priority().
ocfs2_hb_ctl/ocfs2_hb_ctl.c int main(int argc, char **argv) · line 546
Quoted 10 lines
ocfs2_hb_ctl/ocfs2_hb_ctl.c +6
-0@@ -483,6 +538,14 @@ int main(int argc, char **argv) }break ; +case HB_ACTION_IONICE : + err =adjust_priority (&hbo); +if (err) { +com_err (progname, err,"while adjusting heartbeat thread I/O priority" ); + ret = err; + }
You're still printing errors unconditionally.
To break it down, the two errors we don't want to print for are:
* Not finding that the heartbeat region 'pid' attribute exists in configfs. (Should be an O2CB_ET_SERVICE_UNAVAILABLE return)
* Not being able to run /usr/bin/ionice because it doesn't exist. (Should be an OCFS2_ET_NO_IONICE return)
Neither of those two errors should be fatal, or should print to the user. You'll have to filter them from the com_err.
Right now the rule is that all versions of ocfs2-tools must be compatible with old versions of the file system module.
Thanks for the patches so far,
--Mark
--
Mark Fasheh
Senior Software Developer, Oracle
[email protected]