[Patch 2/2] iscsiadm: checking return value of iscsid_req_wait() in iscsid_req_by_rec()

104 views
Skip to first unread message

Yangkook Kim

unread,
Nov 11, 2009, 5:42:22 PM11/11/09
to open-iscsi
This patch adds some codes to output logs to reflect the return value
of iscsid_req_wait() for outputting logging.

Please give me a feedback if any.

-- Yangkook Kim


Signed-off-by: Yangkook Kim <yangk...@gmail.com>

---

--- a/usr/util.c 2009-11-12 06:22:10.000000000 +0900
+++ b/usr/util.c 2009-11-12 06:28:45.000000000 +0900
@@ -121,6 +121,34 @@

#define MAXSLEEP 128

+void iscsid_handle_error(mgmt_ipc_err_e err)
+{
+ static char *err_msgs[] = {
+ /* 0 */ "",
+ /* 1 */ "unknown error",
+ /* 2 */ "not found",
+ /* 3 */ "no available memory",
+ /* 4 */ "encountered connection failure",
+ /* 5 */ "encountered iSCSI login failure",
+ /* 6 */ "encountered iSCSI database failure",
+ /* 7 */ "invalid parameter",
+ /* 8 */ "connection timed out",
+ /* 9 */ "internal error",
+ /* 10 */ "encountered iSCSI logout failure",
+ /* 11 */ "iSCSI PDU timed out",
+ /* 12 */ "iSCSI driver not found. Please make sure it
is loaded, and retry the operation",
+ /* 13 */ "daemon access denied",
+ /* 14 */ "iSCSI driver does not support requested capability.",
+ /* 15 */ "already exists",
+ /* 16 */ "Unknown request",
+ /* 17 */ "encountered iSNS failure",
+ /* 18 */ "could not communicate to iscsid",
+ /* 19 */ "encountered non-retryable iSCSI login failure",
+ /* 20 */ "could not connect to iscsid",
+ };
+ log_error("initiator reported error (%d - %s)", err, err_msgs[err]);
+}
+
static mgmt_ipc_err_e iscsid_connect(int *fd)
{
int nsec;
@@ -231,7 +259,18 @@
err = iscsid_req_by_rec_async(cmd, rec, &fd);
if (err)
return err;
- return iscsid_req_wait(cmd, fd);
+ err = iscsid_req_wait(cmd, fd);
+ if (err) {
+ log_error("Could not login to [iface: %s, target: %s, "
+ "portal: %s,%d]: ", rec->iface.name,
+ rec->name, rec->conn[0].address,
+ rec->conn[0].port);
+ } else
+ printf("Login to [iface: %s, target: %s, portal: "
+ "%s,%d]: successful\n", rec->iface.name,
+ rec->name, rec->conn[0].address,
+ rec->conn[0].port);
+ return err;
}

int iscsid_req_by_sid_async(iscsiadm_cmd_e cmd, int sid, int *fd)
@@ -312,34 +351,6 @@
iface_setup_defaults(&rec->iface);
}

-void iscsid_handle_error(mgmt_ipc_err_e err)
-{
- static char *err_msgs[] = {
- /* 0 */ "",
- /* 1 */ "unknown error",
- /* 2 */ "not found",
- /* 3 */ "no available memory",
- /* 4 */ "encountered connection failure",
- /* 5 */ "encountered iSCSI login failure",
- /* 6 */ "encountered iSCSI database failure",
- /* 7 */ "invalid parameter",
- /* 8 */ "connection timed out",
- /* 9 */ "internal error",
- /* 10 */ "encountered iSCSI logout failure",
- /* 11 */ "iSCSI PDU timed out",
- /* 12 */ "iSCSI driver not found. Please make sure it
is loaded, and retry the operation",
- /* 13 */ "daemon access denied",
- /* 14 */ "iSCSI driver does not support requested capability.",
- /* 15 */ "already exists",
- /* 16 */ "Unknown request",
- /* 17 */ "encountered iSNS failure",
- /* 18 */ "could not communicate to iscsid",
- /* 19 */ "encountered non-retryable iSCSI login failure",
- /* 20 */ "could not connect to iscsid",
- };
- log_error("initiator reported error (%d - %s)", err, err_msgs[err]);
-}
-
int __iscsi_match_session(node_rec_t *rec, char *targetname,
char *address, int port, struct iface_rec *iface)
{

util.c.patch

Mike Christie

unread,
Nov 12, 2009, 11:06:23 AM11/12/09
to open-...@googlegroups.com
Yangkook Kim wrote:
> This patch adds some codes to output logs to reflect the return value
> of iscsid_req_wait() for outputting logging.
>

Thanks for the patch!

It looks like you used the git tree. What branch did you use? I am
asking because I could not find the code below.

Yangkook Kim

unread,
Nov 13, 2009, 2:00:50 PM11/13/09
to open-iscsi
>It looks like you used the git tree. What branch did you use? I am
>asking because I could not find the code below.

I actually did't use git. I just used "diff -Naur file1 file2 > my patch".
and put "signed-off" by myself.

This is actually very first time to send patch and dont't know the correct
manner to send a patch to maintainer. Sorry for making confused you.

Do I have to use git to make patch?

I actually put modified patch of util.c that adds checking
MGMT_IPC_ERR_EXISTS as
I explained in the reply to your question in [Pathch 1/2].

If it would be better if making patch using git, I will do so.

Also I would be very appriciate if you briefly tell me the correct manner
of sending patch to you.

Thanks.

Kim

util.c.patch2

Erez Zilber

unread,
Nov 15, 2009, 3:39:01 AM11/15/09
to open-...@googlegroups.com

What you should do is:

1. Clone the open-iscsi.git tree. The shortest way to do that is:
a. Install git - it usually comes with your distro.
b. Run 'git clone
git://git.kernel.org/pub/scm/linux/kernel/git/mnc/open-iscsi.git'
c. Run 'cd open-iscsi'
2. Now, make some preparations:
a. git repo-config user.name "Yangkook Kim"
b. git repo-config user.email yangk...@gmail.com
3. Make your code changes.
4. Commit you code:
a. Use 'git add' to add the files that you want to have in the commit.
b. After adding all files, you can run 'git diff --cached --color'.
c. Commit your code: 'git commit -s'
d. Write some commit message.
5. Create a patch: use 'git format-patch -n commitish'. For example,
if commit 'A' was the HEAD when you cloned the tree and you make
commits 'B', 'C' & 'D', then 'git format-patch -n A' will create 3
patch files (for 'B', 'C' & 'D'),
6. Check your patches - use checkpatch
(http://lxr.linux.no/#linux+v2.6.31/scripts/checkpatch.pl) to make
sure that your patch has the correct style etc. Run 'checkpatch.pl
--no-tree <your patch file>'.
7. Send your patch.

Good luck,
Erez

Mike Christie

unread,
Nov 16, 2009, 11:43:00 AM11/16/09
to open-...@googlegroups.com
Yangkook Kim wrote:
>> It looks like you used the git tree. What branch did you use? I am
>> asking because I could not find the code below.
>
> I actually did't use git. I just used "diff -Naur file1 file2 > my patch".
> and put "signed-off" by myself.
>
> This is actually very first time to send patch and dont't know the correct
> manner to send a patch to maintainer. Sorry for making confused you.
>
> Do I have to use git to make patch?
>
> I actually put modified patch of util.c that adds checking
> MGMT_IPC_ERR_EXISTS as
> I explained in the reply to your question in [Pathch 1/2].
>
> If it would be better if making patch using git, I will do so.
>

You do not have to make a patch with git. If you do Erez sent a mail
with good instructions on how to set things up.

If you just make a patch with diff, let me know what version of
open-iscsi you are patching against.

Reply all
Reply to author
Forward
0 new messages