Stefan Richter wrote: > I believe your kref_get_not_zero() invention is because you want to > count two unrelated numbers in the same counter. This won't work, I'm > afraid. > > It does work actually, just in a way that people don't seem to like very much. And it is not really my invention; other people have run into the same problem and come up with the same solution. Sometimes people drop kref and go directly to using atomic ops just so that they can use atomic_inc_not_zero() without "violating" the kref API. > One number is > - the number of unfinished transactions (request->response) > of an sg device. (Is that struct sg_device, or struct sg_fd?) > > The other number is > - the number of contexts which peek and poke at the device > representation's memory. (struct sg_device, or struct sg_fd?) > > These two numbers are of course unrelated. Hence I recommend you count > them in separate counters. > > I might be able to get this to work, but is it really better than kref_get_not_zero()? And since there are actually two different types of objects being refcounted with the same issue (sg_fd and sg_device), applying the same "trick" to both might require (ugh) four counters total. Does anyone else favor this approach? I expect that if I put the effort into a patch that does this, someone else will just tell me to do it some other way. But if someone else seconds your proposal, I will give it a try. Please, cast your votes now. Rant: 1) I posted a patch that fixes a bunch of oopses. 2) I was told to use a kref because it makes things "simpler". 3) I posted a second patch using one kref, being very careful to avoid the subtle pitfalls of the kref API. 4) Someone else modified my patch to use two krefs to make things "even simpler", but it was subtly broken because krefs aren't an ideal fit for this problem. 5) I fixed the patch that used two krefs by extending the kref API. 6) I get flamed all to hell. 7) I am told to use three krefs now, using one kref to refcount another kref. However, it may be necessary to use as many as four. 8) I give up being a programmer, move to Wisconsin, and become a dairy farmer. I am of course just joking around and not actually offended, but this whole thing is starting to seem a bit silly. How much more complicated does it have to get just to make things simpler? NIH syndrome, anyone? --Tony "moo cow" Battersby -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html