len = strlen(de->name);
/* filldir returns -EINVAL when the buffer is full. */
-#ifdef AFS_LINUX24_ENV
- code = (*filldir)(dirbuf, de->name, len, offset, ino, DT_DIR);
+#if (defined(AFS_LINUX24_ENV) || defined(pgoff2loff)) && defined(DECLARE_FSTYPE)
+ {
+ unsigned int type=DT_UNKNOWN;
+ struct VenusFid afid;
+ struct vcache *tvc;
+ int vtype;
+ afid.Cell=avc->fid.Cell;
+ afid.Fid.Volume=avc->fid.Fid.Volume;
+ afid.Fid.Vnode=ntohl(de->fid.vnode);
+ afid.Fid.Unique=ntohl(de->fid.vunique);
+ if ((avc->states & CForeign) == 0 &&
+ (ntohl(de->fid.vnode) & 1)) {
+ type=DT_DIR;
+ } else if ((tvc=afs_FindVCache(&afid,0,0,0,0))) {
+ if (tvc->mvstat) {
+ type=DT_DIR;
+ } else if (((tvc->states) & (CStatd|CTruth))) {
+ /* CTruth will be set if the object has
+ *ever* been statd */
+ vtype=vType(tvc);
+ if (vtype == VDIR)
+ type=DT_DIR;
+ else if (vtype == VREG)
+ type=DT_REG;
+ /* Don't do this until we're sure it can't be a mtpt */
+ /* else if (vtype == VLNK)
+ type=DT_LNK; */
+ /* what other types does AFS support? */
+ }
+ /* clean up from afs_FindVCache */
+ afs_PutVCache(tvc, WRITE_LOCK);
+ }
+ code = (*filldir)(dirbuf, de->name, len, offset, ino, type);
+ }
#else
code = (*filldir)(dirbuf, de->name, len, offset, ino);
#endif
int code = 0;
struct vcache *vcp = (struct vcache*)FILE_INODE(fp);
cred_t *credp = crref();
+#ifdef AFS_LINUX24_ENV
+ struct flock64 flock;
+#else
struct flock flock;
+#endif
/* Convert to a lock format afs_lockctl understands. */
memset((char*)&flock, 0, sizeof(flock));
lock_kernel();
#endif
- /* If it's a negative dentry, then there's nothing to do. */
- if (!vcp) {
-#ifdef AFS_LINUX24_ENV
- unlock_kernel();
-#endif
- AFS_GUNLOCK();
- return 0;
- }
-
/* Make this a fast path (no crref), since it's called so often. */
if (vcp->states & CStatd) {
if (*dp->d_name.name != '/' && vcp->mvstat == 2) /* root vnode */
return -code ;
}
-/* Validate a dentry. Return 0 if unchanged, 1 if VFS layer should re-evaluate.
- * In kernels 2.2.10 and above, we are passed an additional flags var which
- * may have either the LOOKUP_FOLLOW OR LOOKUP_DIRECTORY set in which case
- * we are advised to follow the entry if it is a link or to make sure that
- * it is a directory. But since the kernel itself checks these possibilities
- * later on, we shouldn't have to do it until later. Perhaps in the future..
- */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
static int afs_linux_dentry_revalidate(struct dentry *dp, int flags)
#else
int code;
cred_t *credp;
struct vrequest treq;
- struct vcache *vcp = (struct vcache*)dp->d_inode;
-
- AFS_GLOCK();
-#ifdef AFS_LINUX24_ENV
- lock_kernel();
-#endif
-
- /* If it's a negative dentry, then there's nothing to do. */
- if (!vcp) {
-#ifdef AFS_LINUX24_ENV
- unlock_kernel();
-#endif
- AFS_GUNLOCK();
- return 0;
- }
-
- /* Make this a fast path (no crref), since it's called so often. */
- if (vcp->states & CStatd) {
- if (*dp->d_name.name != '/' && vcp->mvstat == 2) /* root vnode */
- check_bad_parent(dp); /* check and correct mvid */
- vcache2inode(vcp);
-#ifdef AFS_LINUX24_ENV
- unlock_kernel();
-#endif
- AFS_GUNLOCK();
- return 0;
+ struct inode *ip = (struct inode *)dp->d_inode;
+
+ unsigned long timeout = 3*HZ; /* 3 seconds */
+
+ if (!(flags & LOOKUP_CONTINUE)) {
+ long diff = CURRENT_TIME - dp->d_parent->d_inode->i_mtime;
+
+ if (diff < 15*60)
+ timeout = 0;
}
-
- credp = crref();
- code = afs_InitReq(&treq, credp);
- if (!code)
- code = afs_VerifyVCache(vcp, &treq);
-
-#ifdef AFS_LINUX24_ENV
- unlock_kernel();
-#endif
- AFS_GUNLOCK();
- crfree(credp);
-
+
+ if (time_after(jiffies, dp->d_time + timeout))
+ goto out_bad;
+
+ out_valid:
return 1;
+
+ out_bad:
+ return 0;
}
/* afs_dentry_iput */
static void afs_dentry_iput(struct dentry *dp, struct inode *ip)
{
-#if defined(AFS_LINUX24_ENV)
- if (atomic_read(&ip->i_count) == 0 || atomic_read(&ip->i_count) & 0xffff0000) {
-#else
- if (ip->i_count == 0 || ip->i_count & 0xffff0000) {
-#endif
- osi_Panic("Bad refCount %d on inode 0x%x\n",
-#if defined(AFS_LINUX24_ENV)
- atomic_read(&ip->i_count), ip);
-#else
- ip->i_count, ip);
-#endif
- }
-#if defined(AFS_LINUX24_ENV)
- atomic_dec(&ip->i_count);
- if (!atomic_read(&ip->i_count)) {
-#else
- ip->i_count --;
- if (!ip->i_count) {
-#endif
- afs_delete_inode(ip);
- }
+ osi_iput(ip);
}
#if defined(AFS_LINUX24_ENV)
#endif
dp->d_op = afs_dops;
+ dp->d_time = jiffies;
d_instantiate(dp, ip);
}
ip->i_op = &afs_symlink_iops;
#endif
}
+ dp->d_time = jiffies;
dp->d_op = afs_dops;
d_add(dp, (struct inode*)vcp);
AFS_GUNLOCK();
if (!code) {
d_delete(dp);
- if (putback)
+ if (putback) {
+ dp->d_time = jiffies;
d_add(dp, NULL); /* means definitely does _not_ exist */
}
+ }
crfree(credp);
return -code;
}
tvcp->v.v_fop = &afs_dir_fops;
#endif
dp->d_op = afs_dops;
+ dp->d_time = jiffies;
d_instantiate(dp, (struct inode*)tvcp);
}
AFS_GUNLOCK();
AFS_GLOCK();
code = afs_rmdir((struct vcache*)dip, name, credp);
- /* Linux likes to see ENOTDIR returned from an rmdir() syscall
+ /* Linux likes to see ENOTEMPTY returned from an rmdir() syscall
* that failed because a directory is not empty. So, we map
- * EEXIST to ENOTDIR on linux.
+ * EEXIST to ENOTEMPTY on linux.
*/
if (code == EEXIST) {
- code = ENOTDIR;
+ code = ENOTEMPTY;
}
if (!code) {
newname, credp);
AFS_GUNLOCK();
- if (!code)
+ if (!code) {
+ /* update time so it doesn't expire immediately */
+ newdp->d_time = jiffies;
d_move(olddp, newdp);
+ }
crfree(credp);
return -code;
{
int code;
cred_t *credp = crref();
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+ char *address;
+ loff_t offset = pp->index << PAGE_CACHE_SHIFT;
+#else
ulong address = afs_linux_page_address(pp);
+ loff_t offset = pageoff(pp);
+#endif
uio_t tuio;
struct iovec iovec;
struct inode *ip = FILE_INODE(fp);
ICL_TYPE_POINTER, pp,
ICL_TYPE_INT32, cnt,
ICL_TYPE_INT32, 99999); /* not a possible code value */
- atomic_add(1, &pp->count);
-#if defined(AFS_LINUX24_ENV)
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+ address = kmap(pp);
ClearPageError(pp);
+
+ lock_kernel();
#else
+ atomic_add(1, &pp->count);
set_bit(PG_locked, &pp->flags); /* other bits? See mm.h */
clear_bit(PG_error, &pp->flags);
#endif
-#if defined(AFS_LINUX24_ENV)
- setup_uio(&tuio, &iovec, (char*)address, pp->index << PAGE_CACHE_SHIFT,
- PAGESIZE, UIO_READ, AFS_UIOSYS);
-#else
- setup_uio(&tuio, &iovec, (char*)address, pageoff(pp), PAGESIZE,
+ setup_uio(&tuio, &iovec, (char*)address, offset, PAGESIZE,
UIO_READ, AFS_UIOSYS);
-#endif
-#ifdef AFS_LINUX24_ENV
- lock_kernel();
-#endif
code = afs_rdwr((struct vcache*)ip, &tuio, UIO_READ, 0, credp);
-#ifdef AFS_LINUX24_ENV
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
unlock_kernel();
#endif
if (tuio.uio_resid) /* zero remainder of page */
memset((void*)(address+(PAGESIZE-tuio.uio_resid)), 0,
tuio.uio_resid);
-#if defined(AFS_LINUX24_ENV)
- SetPageUptodate(pp);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+ flush_dcache_page(pp);
+ SetPageUptodate(pp);
#else
set_bit(PG_uptodate, &pp->flags);
#endif
}
-#if defined(AFS_LINUX24_ENV)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+ kunmap(pp);
UnlockPage(pp);
#else
clear_bit(PG_locked, &pp->flags);
-#endif
wake_up(&pp->wait);
free_page(address);
+#endif
crfree(credp);
afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE,
if (pp->index >= end_index+1 || !offset)
return -EIO;
do_it:
+ AFS_GLOCK();
status = afs_linux_writepage_sync(inode, pp, 0, offset);
+ AFS_GUNLOCK();
SetPageUptodate(pp);
UnlockPage(pp);
- /* kunmap(pp); */
if (status == offset)
return 0;
else
unsigned int count)
{
struct vcache *vcp = (struct vcache *) ip;
- u8 *page_addr = (u8*) afs_linux_page_address(pp);
+ char *buffer;
+ loff_t base;
int code = 0;
cred_t *credp;
uio_t tuio;
struct iovec iovec;
int f_flags = 0;
+ buffer = kmap(pp) + offset;
+ base = (pp->index << PAGE_CACHE_SHIFT) + offset;
+
credp = crref();
- AFS_GLOCK();
- lock_kernel();
afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp,
ICL_TYPE_POINTER, pp,
ICL_TYPE_INT32, atomic_read(&pp->count),
ICL_TYPE_INT32, 99999);
- setup_uio(&tuio, &iovec, page_addr + offset,
- (pp->index << PAGE_CACHE_SHIFT) + offset, count,
- UIO_WRITE, AFS_UIOSYS);
+ setup_uio(&tuio, &iovec, buffer, base, count, UIO_WRITE, AFS_UIOSYS);
code = afs_write(vcp, &tuio, f_flags, credp, 0);
ICL_TYPE_INT32, atomic_read(&pp->count),
ICL_TYPE_INT32, code);
- unlock_kernel();
- AFS_GUNLOCK();
crfree(credp);
+ kunmap(pp);
return code;
}
#if defined(AFS_LINUX24_ENV)
static int afs_linux_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to)
{
- long status;
+ int code;
- /* lock_kernel(); */
- status = afs_linux_updatepage(file, page, offset, to-offset);
- /* unlock_kernel(); */
+ AFS_GLOCK();
+ lock_kernel();
+ code = afs_linux_updatepage(file, page, offset, to-offset);
+ unlock_kernel();
+ AFS_GUNLOCK();
kunmap(page);
- return status;
+ return code;
}
static int afs_linux_prepare_write(struct file *file, struct page *page,
AFS_GLOCK();
lock_kernel();
code = afs_linux_ireadlink(ip, p, PAGE_SIZE, AFS_UIOSYS);
- unlock_kernel();
- AFS_GUNLOCK();
if (code<0)
goto fail;
p[code] = '\0'; /* null terminate? */
+ unlock_kernel();
+ AFS_GUNLOCK();
+
SetPageUptodate(page);
kunmap(page);
UnlockPage(page);
return 0;
fail:
+ unlock_kernel();
+ AFS_GUNLOCK();
+
SetPageError(page);
kunmap(page);
UnlockPage(page);