Skip to contentSkip to conversation

xen/xen-scsiback: Need go to fail after xenbus_dev_error()

PATCH In review Chen Gang 4 participants 21 messages Sep 26, 2014 – Sep 30, 2014

Subsystems (2)
lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 xen/xen-scsiback: Need go to fail after xenbus_dev_error()

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
 drivers/xen/xen-scsiback.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +3 -1
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 
 	err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
 			    SG_ALL);
-	if (err)
+	if (err) {
 		xenbus_dev_error(dev, err, "writing feature-sg-grant");
+		goto fail;
+	}
 
 	xenbus_switch_state(dev, XenbusStateInitWait);
 	return 0;
Signature · 1 line
1.9.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Chen Gang

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
  drivers/xen/xen-scsiback.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +0 -0
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 

drivers/xen/xen-scsiback.c static int scsiback_probe(struct xenbus_device *dev, · line 1231

Quoted 10 lines
drivers/xen/xen-scsiback.c +3 -1
  	err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
  			    SG_ALL);
-	if (err)
+	if (err) {
  		xenbus_dev_error(dev, err, "writing feature-sg-grant");
+		goto fail;
+	}
 
  	xenbus_switch_state(dev, XenbusStateInitWait);
  	return 0;

Hmm, not testing for failure was on purpose. Advertising this feature is just for tuning purposes, not mandatory.

OTOH it would really be a strange error if this xenbus_printf() fails but all other operations are working, and signaling an error at the time when it first shows up is a good thing. So:

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Chen Gang
Quoted 15 lines · Chen Gang

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
  drivers/xen/xen-scsiback.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +0 -0
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 

drivers/xen/xen-scsiback.c static int scsiback_probe(struct xenbus_device *dev, · line 1231

Quoted 10 lines
drivers/xen/xen-scsiback.c +3 -1
  	err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
  			    SG_ALL);
-	if (err)
+	if (err) {
  		xenbus_dev_error(dev, err, "writing feature-sg-grant");
+		goto fail;
+	}
 
  	xenbus_switch_state(dev, XenbusStateInitWait);
  	return 0;

Hmm, not testing for failure was on purpose. Advertising this feature is just for tuning purposes, not mandatory.

OTOH it would really be a strange error if this xenbus_printf() fails but all other operations are working, and signaling an error at the time when it first shows up is a good thing. So:

#3 lore raw
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 29.09.14 at 06:32, <[email protected]> wrote:
Quoted 15 lines · Chen Gang

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
  drivers/xen/xen-scsiback.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +0 -0
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 

drivers/xen/xen-scsiback.c static int scsiback_probe(struct xenbus_device *dev, · line 1231

Quoted 10 lines
drivers/xen/xen-scsiback.c +3 -1
  	err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
  			    SG_ALL);
-	if (err)
+	if (err) {
  		xenbus_dev_error(dev, err, "writing feature-sg-grant");
+		goto fail;
+	}
 
  	xenbus_switch_state(dev, XenbusStateInitWait);
  	return 0;

Hmm, not testing for failure was on purpose. Advertising this feature is just for tuning purposes, not mandatory.

Quoted 3 lines

OTOH it would really be a strange error if this xenbus_printf() fails but all other operations are working, and signaling an error at the time when it first shows up is a good thing. So:

I disagree - failure to announce optional features should not lead to general failure. And this should be consistent across drivers; for existing examples see xen_blkbk_flush_diskcache() and xen_blkbk_discard().

Jan

#4 lore raw
In reply to Juergen Gross
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 29.09.14 at 06:32, <[email protected]> wrote:
Quoted 15 lines · Chen Gang

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
  drivers/xen/xen-scsiback.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +0 -0
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 

drivers/xen/xen-scsiback.c static int scsiback_probe(struct xenbus_device *dev, · line 1231

Quoted 10 lines
drivers/xen/xen-scsiback.c +3 -1
  	err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
  			    SG_ALL);
-	if (err)
+	if (err) {
  		xenbus_dev_error(dev, err, "writing feature-sg-grant");
+		goto fail;
+	}
 
  	xenbus_switch_state(dev, XenbusStateInitWait);
  	return 0;

Hmm, not testing for failure was on purpose. Advertising this feature is just for tuning purposes, not mandatory.

Quoted 3 lines

OTOH it would really be a strange error if this xenbus_printf() fails but all other operations are working, and signaling an error at the time when it first shows up is a good thing. So:

I disagree - failure to announce optional features should not lead to general failure. And this should be consistent across drivers; for existing examples see xen_blkbk_flush_diskcache() and xen_blkbk_discard().

Jan

author
#5 lore raw
Quoted 31 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 29.09.14 at 06:32, <[email protected]> wrote:
Quoted 15 lines · Chen Gang

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
  drivers/xen/xen-scsiback.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +0 -0
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 

drivers/xen/xen-scsiback.c static int scsiback_probe(struct xenbus_device *dev, · line 1231

Quoted 10 lines
drivers/xen/xen-scsiback.c +3 -1
  	err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
  			    SG_ALL);
-	if (err)
+	if (err) {
  		xenbus_dev_error(dev, err, "writing feature-sg-grant");
+		goto fail;
+	}
 
  	xenbus_switch_state(dev, XenbusStateInitWait);
  	return 0;

Hmm, not testing for failure was on purpose. Advertising this feature is just for tuning purposes, not mandatory.

Quoted 9 lines
Quoted 3 lines

OTOH it would really be a strange error if this xenbus_printf() fails but all other operations are working, and signaling an error at the time when it first shows up is a good thing. So:

I disagree - failure to announce optional features should not lead to general failure. And this should be consistent across drivers; for existing examples see xen_blkbk_flush_diskcache() and xen_blkbk_discard().

During scsiback_probe(), can we sure that "feature-sg-grant" is optional feature? For me, only according to its name, I guess not: it is about security which is always necessary in kernel (although SG_ALL).

Thanks

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
maintainer
#6 lore raw
Quoted 42 lines · Chen Gang
Quoted 31 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 29.09.14 at 06:32, <[email protected]> wrote:
Quoted 15 lines · Chen Gang

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
   drivers/xen/xen-scsiback.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +0 -0
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 

drivers/xen/xen-scsiback.c static int scsiback_probe(struct xenbus_device *dev, · line 1231

Quoted 10 lines
drivers/xen/xen-scsiback.c +3 -1
   	err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
   			    SG_ALL);
-	if (err)
+	if (err) {
   		xenbus_dev_error(dev, err, "writing feature-sg-grant");
+		goto fail;
+	}
 
   	xenbus_switch_state(dev, XenbusStateInitWait);
   	return 0;

Hmm, not testing for failure was on purpose. Advertising this feature is just for tuning purposes, not mandatory.

Quoted 9 lines
Quoted 3 lines

OTOH it would really be a strange error if this xenbus_printf() fails but all other operations are working, and signaling an error at the time when it first shows up is a good thing. So:

I disagree - failure to announce optional features should not lead to general failure. And this should be consistent across drivers; for existing examples see xen_blkbk_flush_diskcache() and xen_blkbk_discard().

Quoted 3 lines

During scsiback_probe(), can we sure that "feature-sg-grant" is optional feature? For me, only according to its name, I guess not: it is about security which is always necessary in kernel (although SG_ALL).

It is optional. Otherwise the interface would be broken, as I've added this feature recently and "old" clients (pre 3.18) don't know about it.

The feature is NOT about security, but about capability to support larger SCSI requests than the old interface did.

Juergen

maintainer
#7 lore raw
In reply to Chen Gang
Quoted 42 lines · Chen Gang
Quoted 31 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 29.09.14 at 06:32, <[email protected]> wrote:
Quoted 15 lines · Chen Gang

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
   drivers/xen/xen-scsiback.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +0 -0
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 

drivers/xen/xen-scsiback.c static int scsiback_probe(struct xenbus_device *dev, · line 1231

Quoted 10 lines
drivers/xen/xen-scsiback.c +3 -1
   	err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
   			    SG_ALL);
-	if (err)
+	if (err) {
   		xenbus_dev_error(dev, err, "writing feature-sg-grant");
+		goto fail;
+	}
 
   	xenbus_switch_state(dev, XenbusStateInitWait);
   	return 0;

Hmm, not testing for failure was on purpose. Advertising this feature is just for tuning purposes, not mandatory.

Quoted 9 lines
Quoted 3 lines

OTOH it would really be a strange error if this xenbus_printf() fails but all other operations are working, and signaling an error at the time when it first shows up is a good thing. So:

I disagree - failure to announce optional features should not lead to general failure. And this should be consistent across drivers; for existing examples see xen_blkbk_flush_diskcache() and xen_blkbk_discard().

Quoted 3 lines

During scsiback_probe(), can we sure that "feature-sg-grant" is optional feature? For me, only according to its name, I guess not: it is about security which is always necessary in kernel (although SG_ALL).

It is optional. Otherwise the interface would be broken, as I've added this feature recently and "old" clients (pre 3.18) don't know about it.

The feature is NOT about security, but about capability to support larger SCSI requests than the old interface did.

Juergen

author
#8 lore raw
Quoted 47 lines · Juergen Gross
Quoted 42 lines · Chen Gang
Quoted 31 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 29.09.14 at 06:32, <[email protected]> wrote:
Quoted 15 lines · Chen Gang

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
   drivers/xen/xen-scsiback.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +0 -0
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 

drivers/xen/xen-scsiback.c static int scsiback_probe(struct xenbus_device *dev, · line 1231

Quoted 10 lines
drivers/xen/xen-scsiback.c +3 -1
       err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
                   SG_ALL);
-    if (err)
+    if (err) {
           xenbus_dev_error(dev, err, "writing feature-sg-grant");
+        goto fail;
+    }
 
       xenbus_switch_state(dev, XenbusStateInitWait);
       return 0;

Hmm, not testing for failure was on purpose. Advertising this feature is just for tuning purposes, not mandatory.

Quoted 9 lines
Quoted 3 lines

OTOH it would really be a strange error if this xenbus_printf() fails but all other operations are working, and signaling an error at the time when it first shows up is a good thing. So:

I disagree - failure to announce optional features should not lead to general failure. And this should be consistent across drivers; for existing examples see xen_blkbk_flush_diskcache() and xen_blkbk_discard().

Quoted 3 lines

During scsiback_probe(), can we sure that "feature-sg-grant" is optional feature? For me, only according to its name, I guess not: it is about security which is always necessary in kernel (although SG_ALL).

Quoted 6 lines

It is optional. Otherwise the interface would be broken, as I've added this feature recently and "old" clients (pre 3.18) don't know about it.

The feature is NOT about security, but about capability to support larger SCSI requests than the old interface did.

OK, thanks. All of you said sounds reasonable to me: "it is optional, need print related warning and continue".

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
#9 lore raw
Quoted 5 lines · Chen Gang

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

I think this driver is fine as-is and does not need any changes.

David

author
#10 lore raw
Quoted 9 lines · David Vrabel
Quoted 5 lines · Chen Gang

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

I think this driver is fine as-is and does not need any changes.

OK, at least, at present, it is not a bug (will cause any issue).

But for me, xenbus_dev_error() seems for printing generic errors, dev_warn() is more suitable than it.

And 'fail' code block is useless now, need be removed, too (which will let compiler report warning).

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
maintainer
#11 lore raw
Quoted 8 lines · Chen Gang
Quoted 7 lines · David Vrabel
Quoted 5 lines · Chen Gang

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

Quoted 7 lines
Quoted 2 lines

I think this driver is fine as-is and does not need any changes.

OK, at least, at present, it is not a bug (will cause any issue).

But for me, xenbus_dev_error() seems for printing generic errors, dev_warn() is more suitable than it.

I'm unbiased regarding this one.

Quoted 3 lines

And 'fail' code block is useless now, need be removed, too (which will let compiler report warning).

This should be part of the patch making the 'fail' block useless.

Juergen

author
#12 lore raw
Quoted 12 lines · Juergen Gross
Quoted 11 lines · Chen Gang
Quoted 9 lines · David Vrabel
Quoted 5 lines · Chen Gang

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

I think this driver is fine as-is and does not need any changes.

Quoted 7 lines
Quoted 4 lines

OK, at least, at present, it is not a bug (will cause any issue).

But for me, xenbus_dev_error() seems for printing generic errors, dev_warn() is more suitable than it.

I'm unbiased regarding this one.

After check all related code for xenbus_printf() and xenbus_dev_error(), for me: if xenbus_printf() is for optional error, it will print warning; all xenbus_dev_error() are not for optional error, except 2 area:

drivers/pci/xen-pcifront.c:866: xenbus_dev_error(pdev->xdev, err,
drivers/pci/xen-pcifront.c:947: xenbus_dev_error(pdev->xdev, err,

In fact, for me, not only they need be improved, but also skip 'err' for pcifront_scan_root() and pcifront_rescan_root(), are they bugs? (I guess they are). If they are really bugs, I shall send related patch for it.

Quoted 6 lines
Quoted 3 lines

And 'fail' code block is useless now, need be removed, too (which will let compiler report warning).

This should be part of the patch making the 'fail' block useless.

Yeah, originally, it really should be, but if this patch can continue, for me, can remove it in this patch, too (for the original patch, I intended to remain it for discussing and analysing in this patch).

But all together, if you stick to remove 'fail' code block in original patch, for me, it is OK.

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
author
#13 lore raw
Quoted 21 lines · Chen Gang
Quoted 12 lines · Juergen Gross
Quoted 11 lines · Chen Gang
Quoted 9 lines · David Vrabel
Quoted 5 lines · Chen Gang

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

I think this driver is fine as-is and does not need any changes.

Quoted 7 lines
Quoted 4 lines

OK, at least, at present, it is not a bug (will cause any issue).

But for me, xenbus_dev_error() seems for printing generic errors, dev_warn() is more suitable than it.

I'm unbiased regarding this one.

Quoted 6 lines

After check all related code for xenbus_printf() and xenbus_dev_error(), for me: if xenbus_printf() is for optional error, it will print warning; all xenbus_dev_error() are not for optional error, except 2 area:

drivers/pci/xen-pcifront.c:866: xenbus_dev_error(pdev->xdev, err,
drivers/pci/xen-pcifront.c:947: xenbus_dev_error(pdev->xdev, err,

And for this 2 xenbus_dev_error(), they have no much negative effect (not check return value, and according to the code below, readers can easily understand, they are for optional failure).

But for our case, I recommend to use dev_warn() instead of, or readers is really easy to misunderstand (xenbus_dev_error, and 'grant'), then may send spam again (like me).

Quoted 5 lines

In fact, for me, not only they need be improved, but also skip 'err' for pcifront_scan_root() and pcifront_rescan_root(), are they bugs? (I guess they are). If they are really bugs, I shall send related patch for it.

If no any additional reply for them within 2 days, I shall assume they are bugs, and send related patch for them, in next month (2014-10-??).

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

And 'fail' code block is useless now, need be removed, too (which will let compiler report warning).

This should be part of the patch making the 'fail' block useless.

The original related patch is canceled, so we need not remove 'fail' block (it still seems useful, although it is not).

Quoted 8 lines

Yeah, originally, it really should be, but if this patch can continue, for me, can remove it in this patch, too (for the original patch, I intended to remain it for discussing and analysing in this patch).

But all together, if you stick to remove 'fail' code block in original patch, for me, it is OK.

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
author
#14 lore raw
In reply to Chen Gang
Quoted 21 lines · Chen Gang
Quoted 12 lines · Juergen Gross
Quoted 11 lines · Chen Gang
Quoted 9 lines · David Vrabel
Quoted 5 lines · Chen Gang

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

I think this driver is fine as-is and does not need any changes.

Quoted 7 lines
Quoted 4 lines

OK, at least, at present, it is not a bug (will cause any issue).

But for me, xenbus_dev_error() seems for printing generic errors, dev_warn() is more suitable than it.

I'm unbiased regarding this one.

Quoted 6 lines

After check all related code for xenbus_printf() and xenbus_dev_error(), for me: if xenbus_printf() is for optional error, it will print warning; all xenbus_dev_error() are not for optional error, except 2 area:

drivers/pci/xen-pcifront.c:866: xenbus_dev_error(pdev->xdev, err,
drivers/pci/xen-pcifront.c:947: xenbus_dev_error(pdev->xdev, err,

And for this 2 xenbus_dev_error(), they have no much negative effect (not check return value, and according to the code below, readers can easily understand, they are for optional failure).

But for our case, I recommend to use dev_warn() instead of, or readers is really easy to misunderstand (xenbus_dev_error, and 'grant'), then may send spam again (like me).

Quoted 5 lines

In fact, for me, not only they need be improved, but also skip 'err' for pcifront_scan_root() and pcifront_rescan_root(), are they bugs? (I guess they are). If they are really bugs, I shall send related patch for it.

If no any additional reply for them within 2 days, I shall assume they are bugs, and send related patch for them, in next month (2014-10-??).

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

And 'fail' code block is useless now, need be removed, too (which will let compiler report warning).

This should be part of the patch making the 'fail' block useless.

The original related patch is canceled, so we need not remove 'fail' block (it still seems useful, although it is not).

Quoted 8 lines

Yeah, originally, it really should be, but if this patch can continue, for me, can remove it in this patch, too (for the original patch, I intended to remain it for discussing and analysing in this patch).

But all together, if you stick to remove 'fail' code block in original patch, for me, it is OK.

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
author
#15 lore raw
In reply to Juergen Gross
Quoted 12 lines · Juergen Gross
Quoted 11 lines · Chen Gang
Quoted 9 lines · David Vrabel
Quoted 5 lines · Chen Gang

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

I think this driver is fine as-is and does not need any changes.

Quoted 7 lines
Quoted 4 lines

OK, at least, at present, it is not a bug (will cause any issue).

But for me, xenbus_dev_error() seems for printing generic errors, dev_warn() is more suitable than it.

I'm unbiased regarding this one.

After check all related code for xenbus_printf() and xenbus_dev_error(), for me: if xenbus_printf() is for optional error, it will print warning; all xenbus_dev_error() are not for optional error, except 2 area:

drivers/pci/xen-pcifront.c:866: xenbus_dev_error(pdev->xdev, err,
drivers/pci/xen-pcifront.c:947: xenbus_dev_error(pdev->xdev, err,

In fact, for me, not only they need be improved, but also skip 'err' for pcifront_scan_root() and pcifront_rescan_root(), are they bugs? (I guess they are). If they are really bugs, I shall send related patch for it.

Quoted 6 lines
Quoted 3 lines

And 'fail' code block is useless now, need be removed, too (which will let compiler report warning).

This should be part of the patch making the 'fail' block useless.

Yeah, originally, it really should be, but if this patch can continue, for me, can remove it in this patch, too (for the original patch, I intended to remain it for discussing and analysing in this patch).

But all together, if you stick to remove 'fail' code block in original patch, for me, it is OK.

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
maintainer
#16 lore raw
In reply to Chen Gang
Quoted 8 lines · Chen Gang
Quoted 7 lines · David Vrabel
Quoted 5 lines · Chen Gang

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

Quoted 7 lines
Quoted 2 lines

I think this driver is fine as-is and does not need any changes.

OK, at least, at present, it is not a bug (will cause any issue).

But for me, xenbus_dev_error() seems for printing generic errors, dev_warn() is more suitable than it.

I'm unbiased regarding this one.

Quoted 3 lines

And 'fail' code block is useless now, need be removed, too (which will let compiler report warning).

This should be part of the patch making the 'fail' block useless.

Juergen

author
#17 lore raw
In reply to David Vrabel
Quoted 9 lines · David Vrabel
Quoted 5 lines · Chen Gang

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

I think this driver is fine as-is and does not need any changes.

OK, at least, at present, it is not a bug (will cause any issue).

But for me, xenbus_dev_error() seems for printing generic errors, dev_warn() is more suitable than it.

And 'fail' code block is useless now, need be removed, too (which will let compiler report warning).

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
#18 lore raw
In reply to Chen Gang
Quoted 5 lines · Chen Gang

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

I think this driver is fine as-is and does not need any changes.

David

author
#19 lore raw
In reply to Juergen Gross
Quoted 47 lines · Juergen Gross
Quoted 42 lines · Chen Gang
Quoted 31 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 29.09.14 at 06:32, <[email protected]> wrote:
Quoted 15 lines · Chen Gang

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
   drivers/xen/xen-scsiback.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +0 -0
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 

drivers/xen/xen-scsiback.c static int scsiback_probe(struct xenbus_device *dev, · line 1231

Quoted 10 lines
drivers/xen/xen-scsiback.c +3 -1
       err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
                   SG_ALL);
-    if (err)
+    if (err) {
           xenbus_dev_error(dev, err, "writing feature-sg-grant");
+        goto fail;
+    }
 
       xenbus_switch_state(dev, XenbusStateInitWait);
       return 0;

Hmm, not testing for failure was on purpose. Advertising this feature is just for tuning purposes, not mandatory.

Quoted 9 lines
Quoted 3 lines

OTOH it would really be a strange error if this xenbus_printf() fails but all other operations are working, and signaling an error at the time when it first shows up is a good thing. So:

I disagree - failure to announce optional features should not lead to general failure. And this should be consistent across drivers; for existing examples see xen_blkbk_flush_diskcache() and xen_blkbk_discard().

Quoted 3 lines

During scsiback_probe(), can we sure that "feature-sg-grant" is optional feature? For me, only according to its name, I guess not: it is about security which is always necessary in kernel (although SG_ALL).

Quoted 6 lines

It is optional. Otherwise the interface would be broken, as I've added this feature recently and "old" clients (pre 3.18) don't know about it.

The feature is NOT about security, but about capability to support larger SCSI requests than the old interface did.

OK, thanks. All of you said sounds reasonable to me: "it is optional, need print related warning and continue".

If no any additional reply within 2 days, I shall send patch v2 for it:

"use dev_warn() instead of xenbus_dev_error() and remove 'fail' code block"

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
author
#20 lore raw
In reply to Jan Beulich
Quoted 31 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 29.09.14 at 06:32, <[email protected]> wrote:
Quoted 15 lines · Chen Gang

When failure occurs, after xenbus_dev_error(), need go to fail to let upper caller know about it.

---
  drivers/xen/xen-scsiback.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xen-scsiback.c +0 -0
index 847bc9c..3e430e1 100644
@@ -1222,8 +1222,10 @@ static int scsiback_probe(struct xenbus_device *dev,
 

drivers/xen/xen-scsiback.c static int scsiback_probe(struct xenbus_device *dev, · line 1231

Quoted 10 lines
drivers/xen/xen-scsiback.c +3 -1
  	err = xenbus_printf(XBT_NIL, dev->nodename, "feature-sg-grant", "%u",
  			    SG_ALL);
-	if (err)
+	if (err) {
  		xenbus_dev_error(dev, err, "writing feature-sg-grant");
+		goto fail;
+	}
 
  	xenbus_switch_state(dev, XenbusStateInitWait);
  	return 0;

Hmm, not testing for failure was on purpose. Advertising this feature is just for tuning purposes, not mandatory.

Quoted 9 lines
Quoted 3 lines

OTOH it would really be a strange error if this xenbus_printf() fails but all other operations are working, and signaling an error at the time when it first shows up is a good thing. So:

I disagree - failure to announce optional features should not lead to general failure. And this should be consistent across drivers; for existing examples see xen_blkbk_flush_diskcache() and xen_blkbk_discard().

During scsiback_probe(), can we sure that "feature-sg-grant" is optional feature? For me, only according to its name, I guess not: it is about security which is always necessary in kernel (although SG_ALL).

Thanks

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed