/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/fssnap_if.h>
#include <sys/fdbuffer.h>
#ifdef DEBUG
int evn_ufs_debug = 0;
#else
#endif
/*
* ufs_rdwr_data - supports reading or writing data when
* no changes are permitted in file size or space allocation.
*
* Inputs:
* fdb - The mandatory fdbuffer supports
* the read or write operation.
* flags - defaults (zero value) to synchronous write
* B_READ - indicates read operation
* B_ASYNC - indicates perform operation asynchronously
*/
/*ARGSUSED*/
int
int flags,
{
int curlen = 0;
int pplen;
int contig = 0;
int error = 0;
&protp);
if (error) {
}
return (error);
}
" isize: %llx fdb: %p\n",
}
contig = 0;
break;
}
/*
* If the above assertion is true,
* then the following if statement can never be true.
*/
continue;
}
}
/*
* We may be reading or writing.
*/
if (iswrite) {
printf("**WARNING: ignoring hole in write\n");
} else {
}
continue;
}
if (ufsvfsp->vfs_snapshot) {
} else {
(void) bdev_strategy(bp);
}
io_started = 1;
if (iswrite)
else
fdb_iodone(bp);
}
}
/*
* Show that no more asynchronous IO will be added
*/
}
if (ulp) {
}
return (0);
} else {
return (error);
}
}
/*
* ufs_alloc_data - supports allocating space and reads or writes
* that involve changes to file length or space allocation.
*
* This function is more expensive, because of the UFS log transaction,
* so ufs_rdwr_data() should be used when space or file length changes
* will not occur.
*
* Inputs:
* fdb - A null pointer instructs this function to only allocate
* space for the specified offset and length.
* An actual fdbuffer instructs this function to perform
* the read or write operation.
* flags - defaults (zero value) to synchronous write
* B_READ - indicates read operation
* B_ASYNC - indicates perform operation asynchronously
*/
int
int flags,
{
int contig;
int i_size_changed = 0;
int trans_size;
/* synchronous when non-zero */
/*
* Obey the lockfs protocol
*/
if (error) {
}
return (error);
}
if (ulp) {
/*
* Try to begin a UFS log transaction
*/
trans_size, error);
if (error == EWOULDBLOCK) {
}
return (EDEADLK);
}
}
done_len = 0;
/*
* We are extending the length of the file.
* bmap is used so that we are sure that
* if we need to allocate new blocks, that it
* is done here before we up the file size.
*/
if (error) {
"failed err: %d\n", error));
break;
}
/*
* Desired offset is past end of bytes
* in file, so we have a hole.
*/
nbytes);
} else {
int contig;
&contig);
if (error) {
break;
}
if (ufsvfsp->vfs_snapshot) {
} else {
(void) bdev_strategy(bp);
}
io_started = 1;
fdb_iodone(bp);
if (error) {
break;
}
}
contig);
}
}
}
i_size_changed = 1;
/*
* file has grown larger than 2GB. Set flag
* in superblock to indicate this, if it
* is not already set.
*/
}
} else {
/*
* The file length is not being extended.
*/
if (error) {
"bmap_read err: %d\n", error));
break;
}
/*
* Did not map a hole in the file
*/
if (ufsvfsp->vfs_snapshot) {
} else {
(void) bdev_strategy(bp);
}
io_started = 1;
fdb_iodone(bp);
if (error) {
break;
}
}
}
} else {
/*
* We read a hole in the file.
* We have to allocate blocks for the hole.
*/
if (error) {
" hole failed error: %d\n", error));
break;
}
nbytes);
}
}
}
}
if (error) {
if (i_size_changed) {
/*
* Allocation of the blocks for the file failed.
* So truncate the file size back to its original size.
*/
}
}
} else {
}
/*
* Flush cached pages.
*
* XXX - There should be no pages involved, since the I/O was performed
* through the device strategy routine and the page cache was bypassed.
* However, testing has demonstrated that this VOP_PUTPAGE is
* necessary. Without this, data might not always be read back as it
* was written.
*
*/
/*
* Show that no more asynchronous IO will be added
*/
}
if (ulp) {
/*
* End the UFS Log transaction
*/
}
return (0);
} else {
return (error);
}
}