kernels/linux-2.4.0/fs/nfs/write.c
/*
 * Write a page synchronously.
 * Offset is the data offset within the page.
 */
Write a page synchronously.
Offset is the data offset within the page.
Write a page synchronously . Offset is the data offset within the page .
static int
nfs_writepage_sync(struct file *file, struct inode *inode, struct page *page,
		   unsigned int offset, unsigned int count)
{
	struct rpc_cred	*cred = NULL;
	loff_t		base;
	unsigned int	wsize = NFS_SERVER(inode)->wsize;
	int		result, refresh = 0, written = 0, flags;
	u8		*buffer;
	struct nfs_fattr fattr;
	struct nfs_writeverf verf;
	if (file)
		cred = nfs_file_cred(file);
	lock_kernel();
	dprintk("NFS:      nfs_writepage_sync(%x/%Ld %d@%Ld)\n",
		inode->i_dev, (long long)NFS_FILEID(inode),
		count, (long long)(page_offset(page) + offset));
	buffer = kmap(page) + offset;
	base = page_offset(page) + offset;
	flags = ((IS_SWAPFILE(inode)) ? NFS_RW_SWAP : 0) | NFS_RW_SYNC;
	do {
		if (count < wsize && !IS_SWAPFILE(inode))
			wsize = count;
		result = NFS_PROTO(inode)->write(inode, cred, &fattr, flags,
						 base, wsize, buffer, &verf);
		nfs_write_attributes(inode, &fattr);
		if (result < 0) {
			ClearPageUptodate(page);
			goto io_error;
		}
		if (result != wsize)
			printk("NFS: short write, wsize=%u, result=%d\n",
			wsize, result);
		refresh = 1;
		buffer  += wsize;
	        base    += wsize;
		written += wsize;
		count   -= wsize;
		if (base > inode->i_size)
			inode->i_size = base;
	} while (count);
	if (PageError(page))
		ClearPageError(page);
io_error:
	kunmap(page);
	unlock_kernel();
	return written? written : result;
}
static int nfs_writepage_sync ( struct file * file , struct inode * inode , struct page * page , unsigned int offset , unsigned int count ) { struct rpc_cred * cred = NULL ; loff_t base ; unsigned int wsize = NFS_SERVER ( inode ) -> wsize ; int result , refresh = 0 , written = 0 , flags ; u8 * buffer ; struct nfs_fattr fattr ; struct nfs_writeverf verf ; if ( file ) cred = nfs_file_cred ( file ) ; lock_kernel ( ) ; dprintk ( " \n " , inode -> i_dev , ( long long ) NFS_FILEID ( inode ) , count , ( long long ) ( page_offset ( page ) + offset ) ) ; buffer = kmap ( page ) + offset ; base = page_offset ( page ) + offset ; flags = ( ( IS_SWAPFILE ( inode ) ) ? NFS_RW_SWAP : 0 ) | NFS_RW_SYNC ; do { if ( count < wsize && ! IS_SWAPFILE ( inode ) ) wsize = count ; result = NFS_PROTO ( inode ) -> write ( inode , cred , & fattr , flags , base , wsize , buffer , & verf ) ; nfs_write_attributes ( inode , & fattr ) ; if ( result < 0 ) { ClearPageUptodate ( page ) ; goto io_error ; } if ( result != wsize ) printk ( " \n " , wsize , result ) ; refresh = 1 ; buffer += wsize ; base += wsize ; written += wsize ; count -= wsize ; if ( base > inode -> i_size ) inode -> i_size = base ; } while ( count ) ; if ( PageError ( page ) ) ClearPageError ( page ) ; io_error : kunmap ( page ) ; unlock_kernel ( ) ; return written ? written : result ; }
Write a page synchronously.
Write a page synchronously .
/* Must mark the page invalid after I/O error */ /*
		 * If we've extended the file, update the inode
		 * now so we don't invalidate the cache.
		 */