From patchwork Thu Mar 24 14:39:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 658881 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2OEeh0p012976 for ; Thu, 24 Mar 2011 14:40:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751964Ab1CXOkm (ORCPT ); Thu, 24 Mar 2011 10:40:42 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:34961 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750907Ab1CXOkm (ORCPT ); Thu, 24 Mar 2011 10:40:42 -0400 Received: by bwz15 with SMTP id 15so103708bwz.19 for ; Thu, 24 Mar 2011 07:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer; bh=/sGBreDinBOFU6xDNRIRbFW5EGwGBozvM1e5OW3TZGg=; b=AgCrGBmmTpBgNJ8+Qi4oBr5yhJtzfAtYtURHCfWabkNnGP7cqw/z3bcO+RWnX0Wzcg uaS9a8rPfWAk3i11Bs99bVfcd2E4lZecvhAnuwTbdFtb+yVssa5q+IToJvVSCo64aAru PujLrxcPnf7Cdlmd/REH3e3C+DufUI2rmgvGQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=s8fgshcrqv5vDHmQdD2SzwieuYqLGu8NZ8NephJF9Z7V+6B+AB4LNA9cUM+8U81clR 9Wlp7ZHBXz6CN+grHZjOWwi7KU7k2wA1KLT8bpv3iJ3nfHVp0IWe/UyBiHM8teBvj8ew aIVtv2PMub4aNJPHKKzNNGZ9bxld21zHoprYg= Received: by 10.204.10.81 with SMTP id o17mr3443485bko.94.1300977640035; Thu, 24 Mar 2011 07:40:40 -0700 (PDT) Received: from localhost.localdomain (PPPoE-78-29-116-234.san.ru [78.29.116.234]) by mx.google.com with ESMTPS id y9sm1846090faj.0.2011.03.24.07.40.38 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Mar 2011 07:40:39 -0700 (PDT) From: Pavel Shilovsky To: Jeff Layton , Steve French Cc: linux-cifs@vger.kernel.org Subject: [PATCH] CIFS: Consolidate error handling for cifs_invalidate_mapping Date: Thu, 24 Mar 2011 17:39:47 +0300 Message-Id: <1300977587-8218-1-git-send-email-piastry@etersoft.ru> X-Mailer: git-send-email 1.7.1 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 24 Mar 2011 14:40:43 +0000 (UTC) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index de49fbb..b275d76 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -634,7 +634,13 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) CIFS_I(file->f_path.dentry->d_inode)->time = 0; retval = cifs_revalidate_file(file); - if (retval < 0) + /* + * We only need to get right file length and don't need to + * aware about busy pages (-EBUSY error code). + */ + if (retval == -EBUSY) + retval = 0; + else if (retval < 0) return (loff_t)retval; } return generic_file_llseek_unlocked(file, offset, origin); diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index bb64313..f4391ff 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -61,7 +61,7 @@ extern int cifs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); extern int cifs_revalidate_file(struct file *filp); extern int cifs_revalidate_dentry(struct dentry *); -extern void cifs_invalidate_mapping(struct inode *inode); +extern int cifs_invalidate_mapping(struct inode *inode); extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *); extern int cifs_setattr(struct dentry *, struct iattr *); diff --git a/fs/cifs/file.c b/fs/cifs/file.c index b9731c9..d99cf48 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1448,8 +1448,13 @@ int cifs_strict_fsync(struct file *file, int datasync) cFYI(1, "Sync file - name: %s datasync: 0x%x", file->f_path.dentry->d_name.name, datasync); - if (!CIFS_I(inode)->clientCanCacheRead) - cifs_invalidate_mapping(inode); + if (!CIFS_I(inode)->clientCanCacheRead) { + rc = cifs_invalidate_mapping(inode); + if (rc) { + FreeXid(xid); + return rc; + } + } tcon = tlink_tcon(smbfile->tlink); if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) @@ -1916,8 +1921,13 @@ int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) xid = GetXid(); - if (!CIFS_I(inode)->clientCanCacheRead) - cifs_invalidate_mapping(inode); + if (!CIFS_I(inode)->clientCanCacheRead) { + rc = cifs_invalidate_mapping(inode); + if (rc) { + FreeXid(xid); + return rc; + } + } rc = generic_file_mmap(file, vma); FreeXid(xid); diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index adb6324..d3abfc5 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -1683,27 +1683,25 @@ cifs_inode_needs_reval(struct inode *inode) /* * Zap the cache. Called when invalid_mapping flag is set. */ -void +int cifs_invalidate_mapping(struct inode *inode) { - int rc; + int rc = 0; struct cifsInodeInfo *cifs_i = CIFS_I(inode); - cifs_i->invalid_mapping = false; - if (inode->i_mapping && inode->i_mapping->nrpages != 0) { /* write back any cached data */ rc = filemap_write_and_wait(inode->i_mapping); mapping_set_error(inode->i_mapping, rc); rc = invalidate_inode_pages2(inode->i_mapping); - if (rc) { - cERROR(1, "%s: could not invalidate inode %p", __func__, - inode); - cifs_i->invalid_mapping = true; - } + if (rc) + cFYI(1, "%s: could not invalidate inode %p", __func__, + inode); + cifs_i->invalid_mapping = (rc != 0) ? true : false; } cifs_fscache_reset_inode_cookie(inode); + return rc; } int cifs_revalidate_file(struct file *filp) @@ -1722,7 +1720,7 @@ int cifs_revalidate_file(struct file *filp) check_inval: if (CIFS_I(inode)->invalid_mapping) - cifs_invalidate_mapping(inode); + rc = cifs_invalidate_mapping(inode); return rc; } @@ -1764,7 +1762,7 @@ int cifs_revalidate_dentry(struct dentry *dentry) check_inval: if (CIFS_I(inode)->invalid_mapping) - cifs_invalidate_mapping(inode); + rc = cifs_invalidate_mapping(inode); kfree(full_path); FreeXid(xid); @@ -1776,7 +1774,15 @@ int cifs_getattr(struct vfsmount *mnt, struct dentry *dentry, { struct cifs_sb_info *cifs_sb = CIFS_SB(dentry->d_sb); struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); - int err = cifs_revalidate_dentry(dentry); + int err; + + err = cifs_revalidate_dentry(dentry); + /* + * We only need to get file attributes and don't need to + * aware about busy pages (-EBUSY error code). + */ + if (err == -EBUSY) + err = 0; if (!err) { generic_fillattr(dentry->d_inode, stat);