/*
* 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
*/
/*
*/
/*
* Migration status
*
* Tracking the progress of a shadow migration is tricky business. On the
* surface, it would seem as simple as looking at statvfs(2) output and then
* subtract values from stat(2) as we process each file. Sadly, this only
* works when we are migrating a single filesystem and are starting at the
* root. Because we have to handle migrating sub-directories as well as nested
* filesystems, and there is no way to detect if this is the case over NFS, we
* have to resort to heuristics to guess at the amount of pending data. This
* is also complicated by the fact that, depending on the filesystem, the
* number of blocks in the filesystem may include all metadata, while
* individual files may not.
*
* We can always keep track of the total size of plain file contents that we
* have migrated, but it's much more difficult to estimate how much is
* remaining. There's no good answer here, but we can take a wild swing and
* come up with something that's hopefully useful.
*
* k Number of directory entries migrated
* b Average number of subdirectories in interior directories
* h Average depth of all leaf directories
* r Number of directory entries in the queue
* x Average depth of directory entries in the queue
*
* These can be then fed into the following equation to produce a completion
* percentage:
*
* k
* -------------------------
* k + ln(r) * (b ^ (h - x))
*
* The intent of this equation is to keep track of things with simple global
* constants, but to make sure that it approaches 1 as 'k' gets large.
*
* One possible improvement is to factor the standard deviation into the
* calculation for 'h' so that we assume some pessimistic deeper depth.
*/
#include "shadow_impl.h"
/*
* Called when processing is done for a directory or file. For directories,
* 'size' is the number of sub-directories. For files, it's the total size of
* the file (minus holes).
*/
void
{
if (subdirs == 0) {
} else {
}
}
}
/*
* Called when an entry is added to the queue. If this is a directory, keep
* track of the in-queue statistics.
*/
void
{
return;
}
/*
* Called when an entry is removed from the queue. Only meaningful for
* directories.
*/
void
{
return;
}
/*
* The only user-visible status function. This does the above calculation, and
* then presents the user with a simplified interface (processed and estimated
* remaining).
*/
void
{
double k, b, h, r, x, percent;
k = (double)p->sp_dir_seen;
b = (double)p->sp_dir_seen / p->sp_interior;
h = (double)p->sp_leaf_depth / p->sp_leaf;
r = (double)p->sp_dir_queue;
x = (double)p->sp_dir_depth / p->sp_dir_queue;
#if 0
(void) printf("\n");
(void) printf("k = %f\n", k);
(void) printf("b = %f\n", b);
(void) printf("h = %f\n", h);
(void) printf("r = %f\n", r);
(void) printf("x = %f\n", x);
#endif
ssp->ss_estimated = 0;
else
}
/*
* This function returns details about the current set of errors. It assumes
* that the user has gotten the number of errors from shadow_get_status().
* Because the total number of errors doesn't decrease, we don't have to worry
* if there isn't enough to fill. If the number of errors has subsequently
* risen, we only return what the user has asked for.
*/
{
size_t i;
sizeof (shadow_error_report_t))) == NULL)
return (NULL);
return (NULL);
}
}
return (errors);
}
void
{
size_t i;
for (i = 0; i < count; i++)
}