Commit 854b0fe5 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] dev_t handling cleanups (6/12)

 - hpfs_unlink() should not try to truncate the victim unless it's a
   regular file; truncate will not help for anything else and it will
   screw the page cache if victim happens to be a block device.
 - network filesystems should *not* invalidate page cache of block
   device node when inode gets invalidated; fixed, added a new helper -
   invalidate_remote_inode(). 
 - nfs setattr syncs the file before sending SETATTR to server; that
   makes a lot of sense for regular files, but not for anything else.
   Fixed.
parent c056474c
...@@ -146,7 +146,7 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac ...@@ -146,7 +146,7 @@ int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbac
spin_unlock(&vnode->lock); spin_unlock(&vnode->lock);
if (valid) { if (valid) {
invalidate_inode_pages(inode->i_mapping); invalidate_remote_inode(inode);
afs_put_server(server); afs_put_server(server);
} }
iput(inode); iput(inode);
......
...@@ -569,7 +569,7 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd) ...@@ -569,7 +569,7 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
spin_lock(&AFS_FS_I(inode)->lock); spin_lock(&AFS_FS_I(inode)->lock);
AFS_FS_I(inode)->flags |= AFS_VNODE_DELETED; AFS_FS_I(inode)->flags |= AFS_VNODE_DELETED;
spin_unlock(&AFS_FS_I(inode)->lock); spin_unlock(&AFS_FS_I(inode)->lock);
invalidate_inode_pages(inode->i_mapping); invalidate_remote_inode(inode);
goto out_bad; goto out_bad;
} }
......
...@@ -598,10 +598,12 @@ static int cifs_oplock_thread(void * dummyarg) ...@@ -598,10 +598,12 @@ static int cifs_oplock_thread(void * dummyarg)
netfid = oplock_item->netfid; netfid = oplock_item->netfid;
DeleteOplockQEntry(oplock_item); DeleteOplockQEntry(oplock_item);
write_unlock(&GlobalMid_Lock); write_unlock(&GlobalMid_Lock);
rc = filemap_fdatawrite(inode->i_mapping); if (S_ISREG(inode->i_mode))
if(rc) rc = filemap_fdatawrite(inode->i_mapping);
CIFS_I(inode)->write_behind_rc else
= rc; rc = 0;
if (rc)
CIFS_I(inode)->write_behind_rc = rc;
cFYI(1,("Oplock flush inode %p rc %d",inode,rc)); cFYI(1,("Oplock flush inode %p rc %d",inode,rc));
rc = CIFSSMBLock(0, pTcon, netfid, rc = CIFSSMBLock(0, pTcon, netfid,
0 /* len */ , 0 /* offset */, 0, 0 /* len */ , 0 /* offset */, 0,
......
...@@ -375,6 +375,7 @@ int hpfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -375,6 +375,7 @@ int hpfs_unlink(struct inode *dir, struct dentry *dentry)
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
if (atomic_read(&dentry->d_count) > 1 || if (atomic_read(&dentry->d_count) > 1 ||
permission(inode, MAY_WRITE, NULL) || permission(inode, MAY_WRITE, NULL) ||
!S_ISREG(inode->i_mode) ||
get_write_access(inode)) { get_write_access(inode)) {
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
d_rehash(dentry); d_rehash(dentry);
......
...@@ -620,7 +620,7 @@ nfs_zap_caches(struct inode *inode) ...@@ -620,7 +620,7 @@ nfs_zap_caches(struct inode *inode)
NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode);
NFS_ATTRTIMEO_UPDATE(inode) = jiffies; NFS_ATTRTIMEO_UPDATE(inode) = jiffies;
invalidate_inode_pages(inode->i_mapping); invalidate_remote_inode(inode);
memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
NFS_CACHEINV(inode); NFS_CACHEINV(inode);
...@@ -823,14 +823,15 @@ printk("nfs_setattr: revalidate failed, error=%d\n", error); ...@@ -823,14 +823,15 @@ printk("nfs_setattr: revalidate failed, error=%d\n", error);
goto out; goto out;
} }
if (!S_ISREG(inode->i_mode)) if (!S_ISREG(inode->i_mode)) {
attr->ia_valid &= ~ATTR_SIZE; attr->ia_valid &= ~ATTR_SIZE;
} else {
filemap_fdatawrite(inode->i_mapping); filemap_fdatawrite(inode->i_mapping);
error = nfs_wb_all(inode); error = nfs_wb_all(inode);
filemap_fdatawait(inode->i_mapping); filemap_fdatawait(inode->i_mapping);
if (error) if (error)
goto out; goto out;
}
error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr);
if (error) if (error)
...@@ -1205,7 +1206,7 @@ __nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -1205,7 +1206,7 @@ __nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
if (invalid) { if (invalid) {
nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
nfsi->attrtimeo_timestamp = jiffies; nfsi->attrtimeo_timestamp = jiffies;
invalidate_inode_pages(inode->i_mapping); invalidate_remote_inode(inode);
memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
} else if (time_after(jiffies, nfsi->attrtimeo_timestamp+nfsi->attrtimeo)) { } else if (time_after(jiffies, nfsi->attrtimeo_timestamp+nfsi->attrtimeo)) {
if ((nfsi->attrtimeo <<= 1) > NFS_MAXATTRTIMEO(inode)) if ((nfsi->attrtimeo <<= 1) > NFS_MAXATTRTIMEO(inode))
......
...@@ -212,7 +212,7 @@ smb_set_inode_attr(struct inode *inode, struct smb_fattr *fattr) ...@@ -212,7 +212,7 @@ smb_set_inode_attr(struct inode *inode, struct smb_fattr *fattr)
(long) last_sz, (long) inode->i_size); (long) last_sz, (long) inode->i_size);
if (!S_ISDIR(inode->i_mode)) if (!S_ISDIR(inode->i_mode))
invalidate_inode_pages(inode->i_mapping); invalidate_remote_inode(inode);
} }
} }
...@@ -276,7 +276,7 @@ smb_refresh_inode(struct dentry *dentry) ...@@ -276,7 +276,7 @@ smb_refresh_inode(struct dentry *dentry)
* But we do want to invalidate the caches ... * But we do want to invalidate the caches ...
*/ */
if (!S_ISDIR(inode->i_mode)) if (!S_ISDIR(inode->i_mode))
invalidate_inode_pages(inode->i_mapping); invalidate_remote_inode(inode);
else else
smb_invalid_dir_cache(inode); smb_invalid_dir_cache(inode);
error = -EIO; error = -EIO;
......
...@@ -1176,6 +1176,12 @@ extern int invalidate_partition(struct gendisk *, int); ...@@ -1176,6 +1176,12 @@ extern int invalidate_partition(struct gendisk *, int);
unsigned long invalidate_mapping_pages(struct address_space *mapping, unsigned long invalidate_mapping_pages(struct address_space *mapping,
pgoff_t start, pgoff_t end); pgoff_t start, pgoff_t end);
unsigned long invalidate_inode_pages(struct address_space *mapping); unsigned long invalidate_inode_pages(struct address_space *mapping);
static inline void invalidate_remote_inode(struct inode *inode)
{
if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
S_ISLNK(inode->i_mode))
invalidate_inode_pages(inode->i_mapping);
}
extern void invalidate_inode_pages2(struct address_space *mapping); extern void invalidate_inode_pages2(struct address_space *mapping);
extern void write_inode_now(struct inode *, int); extern void write_inode_now(struct inode *, int);
extern int filemap_fdatawrite(struct address_space *); extern int filemap_fdatawrite(struct address_space *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment