X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=fs%2Fopen.c;h=1d9e5e98bf4e725615cc3cfcd269dc2cab5101e4;hb=21a151d8ca3aa74ee79f9791a9d4dc370d3e0636;hp=a6b054edacba7c4cffa127ceb413120ddd5fe101;hpb=1ff8392c32a2645d2665ca779ecb91bb29361c13;p=linux-2.6-omap-h63xx.git diff --git a/fs/open.c b/fs/open.c index a6b054edacb..1d9e5e98bf4 100644 --- a/fs/open.c +++ b/fs/open.c @@ -256,24 +256,26 @@ static long do_sys_truncate(const char __user * path, loff_t length) if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) goto dput_and_out; - /* - * Make sure that there are no leases. - */ - error = break_lease(inode, FMODE_WRITE); + error = get_write_access(inode); if (error) goto dput_and_out; - error = get_write_access(inode); + /* + * Make sure that there are no leases. get_write_access() protects + * against the truncate racing with a lease-granting setlease(). + */ + error = break_lease(inode, FMODE_WRITE); if (error) - goto dput_and_out; + goto put_write_and_out; error = locks_verify_truncate(inode, NULL, length); if (!error) { DQUOT_INIT(inode); error = do_truncate(nd.dentry, length, 0, NULL); } - put_write_access(inode); +put_write_and_out: + put_write_access(inode); dput_and_out: path_release(&nd); out: @@ -403,7 +405,7 @@ asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len) if (inode->i_op && inode->i_op->fallocate) ret = inode->i_op->fallocate(inode, mode, offset, len); else - ret = -ENOSYS; + ret = -EOPNOTSUPP; out_fput: fput(file);