X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fopen.c;h=e3dfda3bf6a8c9a8b2c2e023b17a8f04e7a0caa3;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=4bd34f4f82f1578d2d09f4eff23ff3d6d5d5addb;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/fs/open.c b/fs/open.c index 4bd34f4f8..e3dfda3bf 100644 --- a/fs/open.c +++ b/fs/open.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -208,10 +208,9 @@ int do_truncate(struct dentry *dentry, loff_t length) newattrs.ia_size = length; newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; + down(&dentry->d_inode->i_sem); - down_write(&dentry->d_inode->i_alloc_sem); err = notify_change(dentry, &newattrs); - up_write(&dentry->d_inode->i_alloc_sem); up(&dentry->d_inode->i_sem); return err; } @@ -859,35 +858,27 @@ repeat: * N.B. For clone tasks sharing a files structure, this test * will limit the total number of files that can be opened. */ - if (fd >= current->rlim[RLIMIT_NOFILE].rlim_cur) + if (fd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) goto out; - /* Do we need to expand the fdset array? */ - if (fd >= files->max_fdset) { - error = expand_fdset(files, fd); - if (!error) { - error = -EMFILE; - goto repeat; - } - goto out; - } - - /* - * Check whether we need to expand the fd array. - */ - if (fd >= files->max_fds) { - error = expand_fd_array(files, fd); - if (!error) { - error = -EMFILE; - goto repeat; - } + /* Do we need to expand the fd array or fd set? */ + error = expand_files(files, fd); + if (error < 0) goto out; + + if (error) { + /* + * If we needed to expand the fs array we + * might have blocked - try again. + */ + error = -EMFILE; + goto repeat; } FD_SET(fd, files->open_fds); FD_CLR(fd, files->close_on_exec); files->next_fd = fd + 1; - // vx_openfd_inc(fd); + vx_openfd_inc(fd); #if 1 /* Sanity check */ if (files->fd[fd] != NULL) { @@ -909,7 +900,7 @@ static inline void __put_unused_fd(struct files_struct *files, unsigned int fd) __FD_CLR(fd, files->open_fds); if (fd < files->next_fd) files->next_fd = fd; - // vx_openfd_dec(fd); + vx_openfd_dec(fd); } void fastcall put_unused_fd(unsigned int fd)