Hello.. I couldn't find a patch for packet writing in 2.4.12, and the patch for 2.4.7 didn't exactly run clearly. So, I gave porting it a try myelf and came to the following: - It now uses a completion record thr_completion instead of thr_sem, because up_and_exit() didn't seem to exist anymore - I added bd_acquire in pkt_setup_dev, because the semaphore i_bdev->bd_count wasn't increased like it should (resulting in an OOPS after closing the cdrw device in pktsetup). As far as I know this is the proper way to do it. - exported bd_acquire,bd_forget,mark_page_accessed from kernel so it can be compiled as module And wow, it even compiles, and works great.. If you think that's useful then get it here: http://goliath.darktech.org/code/packet-0.0.2o-pre1-2.4.12.diff greetings gnufnork
On Mon, 22 Oct 2001 gnufnork@hetdigitalegat.nl wrote:
- I added bd_acquire in pkt_setup_dev, because the semaphore i_bdev->bd_count wasn't increased like it should (resulting in an OOPS after closing the cdrw device in pktsetup). As far as I know this is the proper way to do it. - exported bd_acquire,bd_forget,mark_page_accessed from kernel so it can be compiled as module
I also had this problem when I ported the patch to 2.4.10-pre15, but I fixed it by using the same technique as the loop device uses. The patch looked like this: --- pktcdvd.c.orig Tue Oct 23 19:43:56 2001 +++ pktcdvd.c Tue Oct 23 19:44:06 2001 @@ -2220,6 +2220,8 @@ return 0; } +static int pkt_remove_dev(struct pktcdvd_device *pd); + /* * arg contains file descriptor of CD-ROM device. */ @@ -2244,32 +2246,26 @@ printk("pktcdvd: device is not a block device (duh)\n"); goto out; } - ret = blkdev_get(inode->i_bdev, file->f_mode, file->f_flags, BDEV_FILE); - if (ret) - goto out; ret = -EROFS; if (IS_RDONLY(inode)) { printk("pktcdvd: Can't write to read-only dev\n"); - goto out_bdev; + goto out; } if ((ret = pkt_new_dev(pd, inode->i_rdev, inode->i_bdev))) { printk("pktcdvd: all booked up\n"); - goto out_bdev; + goto out; } - pd->pkt_dentry = dget(file->f_dentry); atomic_inc(&pd->refcnt); + get_file(file); + pd->pkt_file = file; + if ((ret = pkt_lock_tray(pd, PKT_TRAY_LOCK))) { - dput(pd->pkt_dentry); printk("pktcdvd: can't lock drive tray\n"); + pkt_remove_dev(pd); } -out_bdev: - if (ret) { - pd->pkt_dentry = NULL; - blkdev_put(inode->i_bdev, BDEV_FILE); - } out: fput(file); return ret; @@ -2292,8 +2288,7 @@ * will also invalidate buffers for CD-ROM */ invalidate_device(pd->pkt_dev, 1); - blkdev_put(pd->pkt_dentry->d_inode->i_bdev, BDEV_FILE); - dput(pd->pkt_dentry); + fput(pd->pkt_file); (void) pkt_lock_tray(pd, PKT_TRAY_UNLOCK); --- pktcdvd.h.orig Tue Oct 23 19:45:18 2001 +++ pktcdvd.h Tue Oct 23 19:45:22 2001 @@ -173,7 +173,7 @@ __u32 lra; /* last recorded address */ spinlock_t lock; struct packet_cdrw cdrw; - struct dentry *pkt_dentry; + struct file *pkt_file; wait_queue_head_t wqueue; struct request *rq; atomic_t wrqcnt; -- Peter Österlund petero2@telia.com Sköndalsvägen 35 http://w1.894.telia.com/~u89404340 S-128 66 Sköndal +46 8 942647 Sweden
I also had this problem when I ported the patch to 2.4.10-pre15, but I fixed it by using the same technique as the loop device uses. The patch looked like this:
Yeah, that's also a way to do it. This way the module keeps a file open pointing to the device instead of a dir entry object. I don't really see why it should have an opened file though, a reference to the block device would be enough (loopback device is for simulating a block device in a normal file, not another block device.. although that should work too heh..) 'Mounting' pktcdvd on a normal file makes even less sense though :) Having mentioned the word mounting, how does a file system do it? (for a mount should acquire a block device directly in an alike way..) Greetings Wladimir
--- pktcdvd.c.orig Tue Oct 23 19:43:56 2001 +++ pktcdvd.c Tue Oct 23 19:44:06 2001 @@ -2220,6 +2220,8 @@ return 0; }
+static int pkt_remove_dev(struct pktcdvd_device *pd); + /* * arg contains file descriptor of CD-ROM device. */ @@ -2244,32 +2246,26 @@ printk("pktcdvd: device is not a block device (duh)\n"); goto out; } - ret = blkdev_get(inode->i_bdev, file->f_mode, file->f_flags, BDEV_FILE); - if (ret) - goto out; ret = -EROFS; if (IS_RDONLY(inode)) { printk("pktcdvd: Can't write to read-only dev\n"); - goto out_bdev; + goto out; } if ((ret = pkt_new_dev(pd, inode->i_rdev, inode->i_bdev))) { printk("pktcdvd: all booked up\n"); - goto out_bdev; + goto out; }
- pd->pkt_dentry = dget(file->f_dentry); atomic_inc(&pd->refcnt);
+ get_file(file); + pd->pkt_file = file; + if ((ret = pkt_lock_tray(pd, PKT_TRAY_LOCK))) { - dput(pd->pkt_dentry); printk("pktcdvd: can't lock drive tray\n"); + pkt_remove_dev(pd); }
-out_bdev: - if (ret) { - pd->pkt_dentry = NULL; - blkdev_put(inode->i_bdev, BDEV_FILE); - } out: fput(file); return ret; @@ -2292,8 +2288,7 @@ * will also invalidate buffers for CD-ROM */ invalidate_device(pd->pkt_dev, 1); - blkdev_put(pd->pkt_dentry->d_inode->i_bdev, BDEV_FILE); - dput(pd->pkt_dentry); + fput(pd->pkt_file);
(void) pkt_lock_tray(pd, PKT_TRAY_UNLOCK);
--- pktcdvd.h.orig Tue Oct 23 19:45:18 2001 +++ pktcdvd.h Tue Oct 23 19:45:22 2001 @@ -173,7 +173,7 @@ __u32 lra; /* last recorded address */ spinlock_t lock; struct packet_cdrw cdrw; - struct dentry *pkt_dentry; + struct file *pkt_file; wait_queue_head_t wqueue; struct request *rq; atomic_t wrqcnt;
-- Peter �sterlund petero2@telia.com Sk�ndalsv�gen 35 http://w1.894.telia.com/~u89404340 S-128 66 Sk�ndal +46 8 942647 Sweden
participants (2)
-
gnufnork@hetdigitalegat.nl
-
Peter Osterlund