From patchwork Mon Oct 4 17:52:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 229291 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 o94Hs5lE018156 for ; Mon, 4 Oct 2010 17:54:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756251Ab0JDRyU (ORCPT ); Mon, 4 Oct 2010 13:54:20 -0400 Received: from cdptpa-omtalb.mail.rr.com ([75.180.132.120]:45024 "EHLO cdptpa-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755989Ab0JDRyT (ORCPT ); Mon, 4 Oct 2010 13:54:19 -0400 X-Authority-Analysis: v=1.1 cv=lu/RhtYP0ChAeUxMEPBris12a71TWT5f9yvo3GNwP9w= c=1 sm=0 a=GmyMxFm2HmsA:10 a=ld/erqUjW76FpBUqCqkKeA==:17 a=20KFwNOVAAAA:8 a=txcrhl7zgYcWHM3FDzIA:9 a=ZRetuaxs5dbiYqqmZUEA:7 a=ZrNrxRRXOIDXyh66CcIH3Rc7QfUA:4 a=jEp0ucaQiEUA:10 a=ld/erqUjW76FpBUqCqkKeA==:117 X-Cloudmark-Score: 0 X-Originating-IP: 71.70.153.3 Received: from [71.70.153.3] ([71.70.153.3:49713] helo=mail.poochiereds.net) by cdptpa-oedge02.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id 02/B8-14228-E741AAC4; Mon, 04 Oct 2010 17:53:03 +0000 Received: by mail.poochiereds.net (Postfix, from userid 4447) id 25CF65817C; Mon, 4 Oct 2010 13:53:02 -0400 (EDT) From: Jeff Layton To: linux-cifs@vger.kernel.org Subject: [PATCH 07/14] cifs: cifs_write argument change and cleanup Date: Mon, 4 Oct 2010 13:52:54 -0400 Message-Id: <1286214781-626-8-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1286214781-626-1-git-send-email-jlayton@redhat.com> References: <1286214781-626-1-git-send-email-jlayton@redhat.com> 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.3 (demeter1.kernel.org [140.211.167.41]); Mon, 04 Oct 2010 17:54:20 +0000 (UTC) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 0056405c..a1817ed 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -965,8 +965,9 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, return total_written; } -static ssize_t cifs_write(struct file *file, const char *write_data, - size_t write_size, loff_t *poffset) +static ssize_t cifs_write(struct cifsFileInfo *open_file, + const char *write_data, size_t write_size, + loff_t *poffset) { int rc = 0; unsigned int bytes_written = 0; @@ -974,17 +975,14 @@ static ssize_t cifs_write(struct file *file, const char *write_data, struct cifs_sb_info *cifs_sb; struct cifsTconInfo *pTcon; int xid, long_op; - struct cifsFileInfo *open_file; - struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode); + struct dentry *dentry = open_file->dentry; + struct cifsInodeInfo *cifsi = CIFS_I(dentry->d_inode); - cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); + cifs_sb = CIFS_SB(dentry->d_sb); cFYI(1, "write %zd bytes to offset %lld of %s", write_size, - *poffset, file->f_path.dentry->d_name.name); + *poffset, dentry->d_name.name); - if (file->private_data == NULL) - return -EBADF; - open_file = file->private_data; pTcon = tlink_tcon(open_file->tlink); xid = GetXid(); @@ -994,15 +992,6 @@ static ssize_t cifs_write(struct file *file, const char *write_data, total_written += bytes_written) { rc = -EAGAIN; while (rc == -EAGAIN) { - if (file->private_data == NULL) { - /* file has been closed on us */ - FreeXid(xid); - /* if we have gotten here we have written some data - and blocked, and the file has been freed on us - while we blocked so return what we managed to - write */ - return total_written; - } if (open_file->closePend) { FreeXid(xid); if (total_written) @@ -1062,20 +1051,13 @@ static ssize_t cifs_write(struct file *file, const char *write_data, cifs_stats_bytes_written(pTcon, total_written); - /* since the write may have blocked check these pointers again */ - if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) { -/*BB We could make this contingent on superblock ATIME flag too */ -/* file->f_path.dentry->d_inode->i_ctime = - file->f_path.dentry->d_inode->i_mtime = CURRENT_TIME;*/ - if (total_written > 0) { - spin_lock(&file->f_path.dentry->d_inode->i_lock); - if (*poffset > file->f_path.dentry->d_inode->i_size) - i_size_write(file->f_path.dentry->d_inode, - *poffset); - spin_unlock(&file->f_path.dentry->d_inode->i_lock); - } - mark_inode_dirty_sync(file->f_path.dentry->d_inode); + if (total_written > 0) { + spin_lock(&dentry->d_inode->i_lock); + if (*poffset > dentry->d_inode->i_size) + i_size_write(dentry->d_inode, *poffset); + spin_unlock(&dentry->d_inode->i_lock); } + mark_inode_dirty_sync(dentry->d_inode); FreeXid(xid); return total_written; } @@ -1246,8 +1228,8 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to) open_file = find_writable_file(CIFS_I(mapping->host), false); if (open_file) { - bytes_written = cifs_write(open_file->pfile, write_data, - to-from, &offset); + bytes_written = cifs_write(open_file, write_data, + to - from, &offset); cifsFileInfo_put(open_file); /* Does mm or vfs already set times? */ inode->i_atime = inode->i_mtime = current_fs_time(inode->i_sb); @@ -1562,7 +1544,8 @@ static int cifs_write_end(struct file *file, struct address_space *mapping, /* BB check if anything else missing out of ppw such as updating last write time */ page_data = kmap(page); - rc = cifs_write(file, page_data + offset, copied, &pos); + rc = cifs_write(file->private_data, page_data + offset, + copied, &pos); /* if (rc < 0) should we set writebehind rc? */ kunmap(page);