Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Add] Transcend plugin command for PLP health #2355

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

WBJisMyName
Copy link

This function will support the Transcend NVMe Devices.
Please feel free to contact me if you have any question.
Thanks.

@igaw
Copy link
Collaborator

igaw commented Jun 4, 2024

There are code style issues which need to be addressed. see also the output from checkpatch

The rest looks reasonable.

Please also use proper commit subject lines, e.g. with the correct prefix.

thanks

meson.build Outdated Show resolved Hide resolved
plugins/transcend/transcend-nvme.c Outdated Show resolved Hide resolved
plugins/transcend/transcend-nvme.c Outdated Show resolved Hide resolved
plugins/transcend/transcend-nvme.c Outdated Show resolved Hide resolved
plugins/transcend/transcend-nvme.c Show resolved Hide resolved
Copy link
Author

@WBJisMyName WBJisMyName left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update coding style and some errors

@WBJisMyName WBJisMyName requested a review from igaw October 21, 2024 07:30
@ikegami-t
Copy link
Contributor

ikegami-t commented Oct 21, 2024

Build failed and some other error errors also detected by the checks.

@ikegami-t
Copy link
Contributor

ikegami-t commented Oct 22, 2024

  1. Looks all commits should be squashed to a patch since no need to separate the patches to fix the first patch.
  2. The commit message should be followed the description below.
    https://github.com/linux-nvme/nvme-cli/pull/2539/files
  3. Seems basically should be confirmed the contribution guide below at first.
    https://github.com/linux-nvme/nvme-cli/blob/master/README.md#how-to-contribute
  4. The camel case definition and variable naming should be fixed as below for example.
- #define PLPRecordPath "PLPRec.txt"
+ #define PLP_RECORD_PATH "PLPRec.txt"
  ...
- static const int iDis = 20;
+ static const int i_dis = 20;
  ...
- enum PLPErrorCode {
+ enum plp_error_code {

Note: Sorry still not checked detail more so if needed let me comment later.

@WBJisMyName
Copy link
Author

Thanks for your reply, I will fix these errors.

Copy link
Contributor

@ikegami-t ikegami-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better to be mergeged all commits into a commit.

}

int read_useful_plp_value(const char *device)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a static function.

}
}

void record_plp_value(const char *device, int value, bool is_replace)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static function.


#include "define_cmd.h"
#include "define_cmd.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be added a new line code on the end of the line (before the end of file).

static const double full_value = 170;

enum plp_error_code {
PLP_ERROR_NO_MATCH = -1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All indentation should be chagned to 8 character tab instead of the whitespace basically.

PLP_ERROR_DATA_EXPIRED = -2
};

const char *string_list[] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those variables seem better to be static variables.

@@ -5,17 +5,19 @@
#if !defined(TRANSCEND_NVME) || defined(CMD_HEADER_MULTI_READ)
#define TRANSCEND_NVME

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definition is dupulicated with the definition in common.h.

};

static const char *string_list[] = {
"UTE210T", "MTE712P", "MTE560P", "MTE662P", "MTE662P-I", "MTS970P",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still indentation errors. (Should be used 8 characters tab instead of 4 white spaces.)


static int get_health_value(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
struct nvme_smart_log smart_log;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are also indentation errors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your quick reply, I will correct it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkpatch.pl is helpful to detect these kind of formatting issues. You can run it locally. Fetch the linux kernel source and run linux/scripts/checkpatch.pl -g HEAD or similar. Keep in mind checkpatch.pl is very opinionated and we should just be ignored some of the advice.

2. Change function to Static function

Signed-off-by: WBJisMyName <[email protected]>
}

static const char *format_char_array(char *str, int str_size,
unsigned char *chr, int chr_size)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation error.

  tatic const char *format_char_array(char *str, int str_size,
- 				   unsigned char *chr, int chr_size)
+ 				     unsigned char *chr, int chr_size)

}

static int get_plp_health(int argc, char **argv, struct command *cmd,
struct plugin *plugin)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation error.

  static int get_plp_health(int argc, char **argv, struct command *cmd,
- 			 struct plugin *plugin)
+ 			  struct plugin *plugin)

}

/* Calculate PLP health */
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems better to split this part into a separated function.

return -1;
ret = parse_and_open(&dev, argc, argv, desc, opts);
if (ret) {
pr_err("Device not found\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems better to use fprintf(stderr, ...) and printf() instead of the pr_err and pr_info since only this file using the pr_***() funcitons.

} else {
remove(tmp_path);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to insert a line break after } before EOF.

fclose(fp_in);
fclose(fp_out);

if (remove(log_path) == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use braces { and } for the single statement.

static int read_useful_plp_value(const char *device);
static void record_plp_value(const char *device, int value, bool is_replace);

static int get_health_value(int argc, char **argv, struct command *cmd,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems better to split this function related changes to other patch.

}

static int getBadblock(int argc, char **argv, struct command *cmd, struct plugin *plugin)
static int get_bad_block(int argc, char **argv, struct command *cmd,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems better to split this function related changes also to other patch since not related to the plphealthvalue command.

@igaw
Copy link
Collaborator

igaw commented Nov 11, 2024

There are build errors which need to be address, e.g. there is no pr_err or pr_info macro or function. And the three unused function as well.

The documentation should also be hooked up:

--- a/Documentation/meson.build
+++ b/Documentation/meson.build
@@ -148,6 +148,7 @@ adoc_sources = [
   'nvme-toshiba-vs-smart-add-log',
   'nvme-transcend-badblock',
   'nvme-transcend-healthvalue',
+  'nvme-transcend-plphealthvalue',
   'nvme-verify',
   'nvme-virtium-save-smart-to-vtview-log',
   'nvme-virtium-show-identify',

The rest looks almost there (after squashing all changes into a single patch). A few small nitpicks which I'd address myself but as it doesn't build right now, please fix the build and I'd cleanup the rest.

@igaw
Copy link
Collaborator

igaw commented Dec 20, 2024

Are you planing to address the remaining issues? Or is this PR abandoned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants