[Ocfs2-tools-devel] [PATCH 12/22] tunefs rework: Add op_set_slot_count.c
Tao Ma
tao.ma at oracle.com
Thu Jul 31 19:49:01 PDT 2008
Joel Becker wrote:
> The set_slot_count operation changes the number of node slots on an
> ocfs2 filesystem. Each slot has a journal and other associated files.
> The number of slots is the number of nodes that can share the
> filesystem. All filesystems must have at least one slot.
>
> This is the tunefs option '-N'.
>
> Signed-off-by: Joel Becker <joel.becker at oracle.com>
> +static int set_slot_count_parse_option(struct tunefs_operation *op,
> + char *arg)
> +{
> + int rc = 1;
> + char *ptr = NULL;
> + long num_slots;
> +
> + if (!arg) {
> + errorf("Number of slots not specified\n");
> + goto out;
> + }
> +
> + num_slots = strtol(arg, &ptr, 10);
> + if ((num_slots == LONG_MIN) || (num_slots == LONG_MAX)) {
> + errorf("Number of slots is out of range: %s\n", arg);
> + goto out;
> + }
> + if (*ptr != '\0') {
> + errorf("Invalid number: \"%s\"\n", arg);
> + goto out;
> + }
> + if (num_slots < 1) {
> + errorf("At least one slot required\n");
> + goto out;
> + }
> + if (num_slots > INT_MAX) {
> + errorf("Number of slots is out of range: %s\n", arg);
> + goto out;
> + }
> + /*
> + * We'll check the maximum number of slots after we've opened
> + * the filesystem and determined the slot map format.
> + */
> +
> + op->to_private = (void *)num_slots;
> + rc = 0;
> +
> +out:
> + return rc;
> +}
> +
> +static int set_slot_count_run(struct tunefs_operation *op,
> + ocfs2_filesys *fs, int flags)
> +{
> + errcode_t err;
> + int rc = 0;
> + int num_slots = (int)op->to_private;
In set_slot_count_parse_option you define num_slots as "long" and here
you use "int". Actually it will not cause problem sine we can never has
such a big num_slots. But should we use the same type?
Regards,
Tao
More information about the Ocfs2-tools-devel
mailing list