?

Log in

No account? Create an account
Pete Zaitcev's Journal -- Day [entries|friends|calendar]
Pete Zaitcev

[ userinfo | livejournal userinfo ]
[ calendar | livejournal calendar ]

[01 Aug 2004|02:33pm]
I am starting to have a terrible love-hate relationship with ub, and a relationship from which I cannot get away.

The pressure of real life requirements makes ub to grow rapidly, and I have grave concerns over my ability to manage the growth. These concerns flow from the overall size and complexity of the code, and the way features push the development on their own, making me a 150 knot pilot in a 300 knot airplane.

The size is vaguely larger than I anticipated now, and ub is going to be bigger yet. This is bad, because if I went away for a month and re-read the code, would it still be clear? Would it fit into my mind? I'm afraid it won't. My mind is quite small and once a design leaks from it, it's gone. I really need to create some classes or modules with clean interfaces, but there's no time. I wish someone took ub and made ufi out of it, just to force factorization this way.

The first bigger feature that forced my hand was the support for removable media, such as CF cards and CDs. It turned out that Linux block layer does not perform its media checks on its own. In other words, it's not enough to add methods for media check, I had to add open and close routines. This caused me to re-examine the way everything was reference-counted and made for some really hideous spinlock jiggling, in the worst kind of Solaris coding style. I made it somewhat more palatable by employing an atomic_t, my first atomic_t ever. The last time I had to do such bizarre convolutions was when I fixed khubd oopses in 2.4.9 or so. At that time I did it poorly, this time a little better, but not well.

The latest upheaval is caused by the command queuing. It looks like a very straightforward aspect of a driver. Sure, I coded it 20 times before! However, the need to fetch next command once the current one is done created a dispatch loop, which is a technique I really hate for its readability problems (and its ability to loop forever with interrupts closed). A reader has to follow code up and down and to deduce or second guess things like that two sorts of states exist: ones with active URBs (processed inside the state machine switch) and ones without active URBs (processed in the dispatch function). This is a really annoying mess. Also, since I have decided not to return callbacks from inside the initial submission path, and the dispatch loop does return them even for the command just submitted (it cannot return an error code), the submission awakens a tasklet to run the dispatch loop instead of doing it right away. Well, at least we have an extra voluntary preemption point now, har har har. Ahem...

To top it all off, AKPM sent me a patch for compilation warnings. Obviously, a genuine need exists for ub, or better said, a usb-storage done right, which ub might or or might not be. So I cannot just say, "You know guys, this is a little harder than I thought, so just keep using that usb-storage crap".
post comment

navigation
[ viewing | August 1st, 2004 ]
[ go | previous day|next day ]