#include "osi_compat.h"
#include "osi_pagecopy.h"
-#ifndef HAVE_PAGEVEC_LRU_ADD_FILE
+#ifndef HAVE_LINUX_PAGEVEC_LRU_ADD_FILE
#define __pagevec_lru_add_file __pagevec_lru_add
#endif
#define MAX_ERRNO 1000L
#endif
-extern struct backing_dev_info afs_backing_dev_info;
+extern struct backing_dev_info *afs_backing_dev_info;
extern struct vcache *afs_globalVp;
extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp);
flock.l_pid = flp->fl_pid;
flock.l_whence = 0;
flock.l_start = flp->fl_start;
- flock.l_len = flp->fl_end - flp->fl_start + 1;
+ if (flp->fl_end == OFFSET_MAX)
+ flock.l_len = 0; /* Lock to end of file */
+ else
+ flock.l_len = flp->fl_end - flp->fl_start + 1;
/* Safe because there are no large files, yet */
#if defined(F_GETLK64) && (F_GETLK != F_GETLK64)
flp->fl_type = flock.l_type;
flp->fl_pid = flock.l_pid;
flp->fl_start = flock.l_start;
- flp->fl_end = flock.l_start + flock.l_len - 1;
+ if (flock.l_len == 0)
+ flp->fl_end = OFFSET_MAX; /* Lock to end of file */
+ else
+ flp->fl_end = flock.l_start + flock.l_len - 1;
crfree(credp);
return afs_convert_code(code);
flock.l_pid = flp->fl_pid;
flock.l_whence = 0;
flock.l_start = 0;
- flock.l_len = OFFSET_MAX;
+ flock.l_len = 0;
/* Safe because there are no large files, yet */
#if defined(F_GETLK64) && (F_GETLK != F_GETLK64)
struct file_operations afs_file_fops = {
.read = afs_linux_read,
.write = afs_linux_write,
-#ifdef GENERIC_FILE_AIO_READ
+#ifdef HAVE_LINUX_GENERIC_FILE_AIO_READ
.aio_read = generic_file_aio_read,
.aio_write = generic_file_aio_write,
#endif
check_bad_parent(struct dentry *dp)
{
cred_t *credp;
- struct vcache *vcp = VTOAFS(dp->d_inode), *avc = NULL;
- struct vcache *pvc = VTOAFS(dp->d_parent->d_inode);
+ struct dentry *parent;
+ struct vcache *vcp, *pvc, *avc = NULL;
+
+ vcp = VTOAFS(dp->d_inode);
+ parent = dget_parent(dp);
+ pvc = VTOAFS(parent->d_inode);
if (vcp->mvid->Fid.Volume != pvc->f.fid.Fid.Volume) { /* bad parent */
credp = crref();
crfree(credp);
}
+ dput(parent);
+
return;
}
struct vattr vattr;
cred_t *credp = NULL;
struct vcache *vcp, *pvcp, *tvc = NULL;
+ struct dentry *parent;
int valid;
struct afs_fakestat_state fakestate;
afs_InitFakeStat(&fakestate);
if (dp->d_inode) {
-
vcp = VTOAFS(dp->d_inode);
- pvcp = VTOAFS(dp->d_parent->d_inode); /* dget_parent()? */
if (vcp == afs_globalVp)
goto good_dentry;
}
#endif
+ parent = dget_parent(dp);
+ pvcp = VTOAFS(parent->d_inode);
+
/* If the parent's DataVersion has changed or the vnode
* is longer valid, we need to do a full lookup. VerifyVCache
* isn't enough since the vnode may have been renamed.
credp = crref();
afs_lookup(pvcp, (char *)dp->d_name.name, &tvc, credp);
- if (!tvc || tvc != vcp)
+ if (!tvc || tvc != vcp) {
+ dput(parent);
goto bad_dentry;
+ }
- if (afs_getattr(vcp, &vattr, credp))
+ if (afs_getattr(vcp, &vattr, credp)) {
+ dput(parent);
goto bad_dentry;
+ }
vattr2inode(AFSTOV(vcp), &vattr);
dp->d_time = hgetlo(pvcp->f.m.DataVersion);
/* should we always update the attributes at this point? */
/* unlikely--the vcache entry hasn't changed */
+ dput(parent);
} else {
#ifdef notyet
- pvcp = VTOAFS(dp->d_parent->d_inode); /* dget_parent()? */
+ /* If this code is ever enabled, we should use dget_parent to handle
+ * getting the parent, and dput() to dispose of it. See above for an
+ * example ... */
+ pvcp = VTOAFS(dp->d_parent->d_inode);
if (hgetlo(pvcp->f.m.DataVersion) > dp->d_time)
goto bad_dentry;
#endif
if (afs_linux_bypass_check(inode))
return afs_linux_bypass_readpages(fp, mapping, page_list, num_pages);
+ if (cacheDiskType == AFS_FCACHE_TYPE_MEM)
+ return 0;
+
AFS_GLOCK();
if ((code = afs_linux_VerifyVCache(avc, NULL))) {
AFS_GUNLOCK();
/* Grab the creds structure currently held in the vnode, and
* get a reference to it, in case it goes away ... */
credp = vcp->cred;
- crhold(credp);
+ if (credp)
+ crhold(credp);
+ else
+ credp = crref();
ReleaseWriteLock(&vcp->lock);
AFS_GUNLOCK();
return 0;
}
-#if defined(HAVE_WRITE_BEGIN)
+#if defined(STRUCT_ADDRESS_SPACE_OPERATIONS_HAS_WRITE_BEGIN)
static int
afs_linux_write_end(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned copied,
.readpage = afs_linux_readpage,
.readpages = afs_linux_readpages,
.writepage = afs_linux_writepage,
-#if defined (HAVE_WRITE_BEGIN)
+#if defined (STRUCT_ADDRESS_SPACE_OPERATIONS_HAS_WRITE_BEGIN)
.write_begin = afs_linux_write_begin,
.write_end = afs_linux_write_end,
#else
static struct inode_operations afs_symlink_iops = {
#if defined(USABLE_KERNEL_PAGE_SYMLINK_CACHE)
.readlink = page_readlink,
-# if defined(HAVE_KERNEL_PAGE_FOLLOW_LINK)
+# if defined(HAVE_LINUX_PAGE_FOLLOW_LINK)
.follow_link = page_follow_link,
# else
.follow_link = page_follow_link_light,
if (vattr)
vattr2inode(ip, vattr);
- ip->i_mapping->backing_dev_info = &afs_backing_dev_info;
+ ip->i_mapping->backing_dev_info = afs_backing_dev_info;
/* Reset ops if symlink or directory. */
if (S_ISREG(ip->i_mode)) {
ip->i_op = &afs_file_iops;