patch for 2.1.45-7 wrapping counts

Bill Hawes (whawes@star.net)
Wed, 16 Jul 1997 12:54:09 -0400


This is a multi-part message in MIME format.
--------------3DCD249FD223844A661BE305
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Thanks for the tip on oops-generation. I tracked down the wrapped count
problem -- in sock_alloc the socket keeps a reference to the inode, so
when the file is closed, the inode is iputted twice. I fixed it by
incrementing the inode count after a successful d_alloc_root.

It appears that since sock_alloc is a public function, there may be some
uses of sockets that don't get a dentry reference. Alternatively, if
sock_alloc could be made private, then all uses of sockets would go
through get_fd, and the iput() in sock_release could be removed.

I've also included a patch for fs/proc/root.c, to remove an unneeded
iput() and an atomic_inc(&dir->i_count). (I'm not positive about these,
but the other lookup functions don't iput the dir or increment its
count).

With these changes in place, -7 boots and runs cleanly. Will continue
to test ...

Regards,
Bill
--------------3DCD249FD223844A661BE305
Content-Type: text/plain; charset=us-ascii; name="wrap_45-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="wrap_45-patch"

--- net/socket.c.old Wed Jul 16 06:44:09 1997
+++ net/socket.c Wed Jul 16 12:31:21 1997
@@ -206,11 +206,21 @@
return -ENFILE;
}

+ if (!(file->f_dentry = d_alloc_root(inode, NULL))) {
+ put_filp(file);
+ put_unused_fd(fd);
+ return -ENOMEM;
+ }
+ /*
+ * The socket maintains a reference to the inode, so we
+ * have to increment the count.
+ */
+ atomic_inc(&inode->i_count);
+
current->files->fd[fd] = file;
file->f_op = &socket_file_ops;
file->f_mode = 3;
file->f_flags = O_RDWR;
- file->f_dentry = d_alloc_root(inode, NULL);
file->f_pos = 0;
}
return fd;
--- fs/proc/root.c.old Wed Jul 9 07:18:27 1997
+++ fs/proc/root.c Wed Jul 16 11:42:17 1997
@@ -227,7 +227,6 @@
proc_openprom_deflookup)
return proc_openprom_inode_operations.lookup
(dir, str, result);
- iput(dir);
return -ENOENT;
}
#endif
@@ -658,8 +657,6 @@
struct task_struct *p;
const char *name;
int len;
-
- atomic_inc(&dir->i_count);

if (dir->i_ino == PROC_ROOT_INO) { /* check for safety... */
dir->i_nlink = proc_root.nlink;

--------------3DCD249FD223844A661BE305--