Skip to contentSkip to conversation

drivers/scsi: fixing wrong comment before new_buffer_tape()

PATCH In review Lin Tan 4 participants 7 messages Sep 25, 2008 – Sep 26, 2008 SCSI

lore
Share & tools
lore

Lin Tan

author
#0 lore raw

PATCH 1/1 drivers/scsi: fixing wrong comment before new_buffer_tape()

(I would wish to be personally CC'ed the answers/comments posted to the list in response to my posting.)

---

Removing the wrong comment.
The lock is needed before calling new_tape_buffer(), at least in some cases. So the comment above new_tape_buffer() is inconsistent with the code and may mislead developers.

I simply removed the wrong comment, as I am not sure if the lock is required in all situations. If so, we should add "Caller must hold os_scsi_tapes_lock".

---

drivers/scsi/osst.c +1 -1
@@ -5209,7 +5209,7 @@
 
 /* Memory handling routines */
 
-/* Try to allocate a new tape buffer skeleton. Caller must not hold os_scsi_tapes_lock */
+/* Try to allocate a new tape buffer skeleton. */
 static struct osst_buffer * new_tape_buffer( int from_initialization, int need_dma, int max_sg )
 {
 	int i;
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Thu, 25 Sep 2008 12:49:48 -0500 Lin Tan <[email protected]> wrote:

(I would wish to be personally CC'ed the answers/comments posted to the list in response to my posting.)

---

Removing the wrong comment.
The lock is needed before calling new_tape_buffer(), at least in some cases. So the comment above new_tape_buffer() is inconsistent with the code and may mislead developers.

Quoted 4 lines

I simply removed the wrong comment, as I am not sure if the lock is required in all situations. If so, we should add "Caller must hold os_scsi_tapes_lock".

Looks true to me for the current versions of the code. In fact it is only ever called from the initialisation function that I can see so chunks of the code could simply go away as well as bits of the comment. Ditto the one in drivers/scsi/st.c

author
#2 lore raw
Quoted 8 lines
Quoted 8 lines

Removing the wrong comment.
The lock is needed before calling new_tape_buffer(), at least in some cases. So the comment above new_tape_buffer() is inconsistent with the code and may mislead developers.

I simply removed the wrong comment, as I am not sure if the lock is required in all situations. If so, we should add "Caller must hold os_scsi_tapes_lock".

Quoted 9 lines
Quoted 1 line

Looks true to me for the current versions of the code. In fact it is only ever called from the initialisation function that I can see so chunks of the code could simply go away as well as bits of the comment. Ditto the one in drivers/scsi/st.c

I am sorry I didn't quite understand. You mean it is true that caller must hold os_scsi_tapes_lock?

new_tape_buffer in drivers/scsi/st.c is called without the lock, but the new_tape_buffer in drivers/scsi/osst.c
is called with the lock. Both comments says no lock is needed. Should the two new_tap_buffer functions have similar usage?

BTW, I am on the mailing list now, so I no longer need to be personally CC-ed. Thanks.

Lin

#3 lore raw
Quoted 10 lines
Quoted 7 lines

Looks true to me for the current versions of the code. In fact it is only ever called from the initialisation function that I can see so chunks of the code could simply go away as well as bits of the comment. Ditto the one in drivers/scsi/st.c

I am sorry I didn't quite understand. You mean it is true that caller must hold os_scsi_tapes_lock?

Sorry - I mean what you claim is true - that the comment is incorrect.

maintainer
#4 lore raw
Quoted 5 lines · Alan Cox
Quoted 5 lines
Quoted 5 lines

Looks true to me for the current versions of the code. In fact it is only ever called from the initialisation function that I can see so chunks of the code could simply go away as well as bits of the comment. Ditto the one in drivers/scsi/st.c

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I am sorry I didn't quite understand. You mean it is true that caller must hold os_scsi_tapes_lock?

Sorry - I mean what you claim is true - that the comment is incorrect.

So, I think I'm missing a piece of this: There's no patch in this thread (I presume it's lurking somewhere on lkml). Could someone repost the proposed patch and copy the tape maintainer: Kai Makisara <[email protected]> to get his input?

Thanks,

James

author
#5 lore raw
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Looks true to me for the current versions of the code. In fact it is only ever called from the initialisation function that I can see so chunks of the code could simply go away as well as bits of the comment. Ditto the one in drivers/scsi/st.c

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I am sorry I didn't quite understand. You mean it is true that caller must hold os_scsi_tapes_lock?

Sorry - I mean what you claim is true - that the comment is incorrect.

Quoted 10 lines

So, I think I'm missing a piece of this: There's no patch in this thread (I presume it's lurking somewhere on lkml). Could someone repost the proposed patch and copy the tape maintainer: Kai Makisara <[email protected]> to get his input?

Thanks,

James

The patch was in the orginal message. I am resending it now with Makisara CC-ed.

Lin

Removing the wrong comment.
The lock is needed before calling new_tape_buffer(), at least in some cases. So the comment above new_tape_buffer() is inconsistent with the code and may mislead developers.

I simply removed the wrong comment, as I am not sure if the lock is required in all situations. If so, we should add "Caller must hold os_scsi_tapes_lock".

---

drivers/scsi/osst.c +1 -1
@@ -5209,7 +5209,7 @@
 
 
 /* Memory handling routines */
 
-/* Try to allocate a new tape buffer skeleton. Caller must not hold os_scsi_tapes_lock */
+/* Try to allocate a new tape buffer skeleton. */
 static struct osst_buffer * new_tape_buffer( int from_initialization, int need_dma, int max_sg )
 {

int i;

#6 lore raw

I am talking only about st.c but most of this probably applies also to osst.c.

Quoted 3 lines · Lin Tan
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Looks true to me for the current versions of the code. In fact it is only ever called from the initialisation function that I can see so chunks of the code could simply go away as well as bits of the comment. Ditto the

It is true that the function is currently called only from initialisation. It was called from other contexts earlier and the extra code is leftover from that time.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

one in drivers/scsi/st.c

I am sorry I didn't quite understand. You mean it is true that caller must hold os_scsi_tapes_lock?

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Sorry - I mean what you claim is true - that the comment is incorrect.

So, I think I'm missing a piece of this: There's no patch in this thread (I presume it's lurking somewhere on lkml). Could someone repost the proposed patch and copy the tape maintainer: Kai Makisara <[email protected]> to get his input?

I saw the patch but my mail client does not include attachments as text in reply ;-(

Anyway, the comment is there because new_tape_buffer() may sleep and st_dev_arr_lock is a spinlock. I have been under the impression that code inside a spinlock must not sleep.

When called from initialisation, new_tape_buffer() _currently_ used GFP_ATOMIC. I am not sure that this is necessary but as long as I don't know, I don't want to change it. The comment protects callers even if someone knows that it is safe to use GFP_KERNEL from initialisation.

I don't see why new_tape_buffer() needs to be inside the lock. It just allocates an initialises a structure.

If someone wants to remove the comment from st.c, I don't mind. But please make sure that what you write to the commit is correct.

Kai