Skip to content
Snippets Groups Projects
Commit 934fbbfc authored by Steven Murray's avatar Steven Murray
Browse files

bug #103710: RFE: vmgr should always choose the tape with the least free space for writing

Fixed in the v2_1_14Version branch.
parent 6daab363
No related branches found
No related tags found
No related merge requests found
......@@ -726,9 +726,8 @@ int vmgr_get_side_by_size_byte_u64(struct vmgr_dbfd *dbfd,
struct sqlca sqlca;
char estimated_free_space_byte_str[21];
/* Try to find the five tapes with the least amount of free space that have */
/* enough space to satisfy the specified request size, then pick one of */
/* those tapes at random. */
/* Find the five tapes with the least amount of free space and pick one */
/* of them at random */
EXEC SQL DECLARE tape_size_cursor4upd CURSOR FOR
SELECT ROWID, vid, side, poolname, status, TO_CHAR(estimated_free_space),
nbfiles
......@@ -749,41 +748,12 @@ int vmgr_get_side_by_size_byte_u64(struct vmgr_dbfd *dbfd,
AND vmgr_tape_library.status = 0
AND vmgr_tape_side.poolname = :poolname
AND vmgr_tape_side.status = 0
AND vmgr_tape_side.estimated_free_space >= :reqsize
ORDER BY vmgr_tape_side.estimated_free_space asc, DBMS_RANDOM.VALUE)
WHERE rownum <= 5)
ORDER BY DBMS_RANDOM.VALUE)
WHERE ROWNUM < 2)
FOR UPDATE;
/* Try to find the five tapes with the most amount of free space and then */
/* choose one of them at random */
EXEC SQL DECLARE tape_maxsize_cursor4upd CURSOR FOR
SELECT ROWID, vid, side, poolname, status, TO_CHAR(estimated_free_space),
nbfiles
FROM vmgr_tape_side
WHERE
vmgr_tape_side.vid = (
SELECT vid
FROM (
SELECT vid
FROM (
SELECT vid
FROM (
SELECT vmgr_tape_side.vid
FROM vmgr_tape_side, vmgr_tape_info, vmgr_tape_library
WHERE
vmgr_tape_side.vid = vmgr_tape_info.vid
AND vmgr_tape_info.library = vmgr_tape_library.name
AND vmgr_tape_library.status = 0
AND vmgr_tape_side.poolname = :poolname
AND vmgr_tape_side.status = 0
ORDER BY vmgr_tape_side.estimated_free_space desc, DBMS_RANDOM.VALUE)
WHERE rownum <= 5)
ORDER BY DBMS_RANDOM.VALUE)
WHERE ROWNUM < 2)
FOR UPDATE;
strncpy (func, "vmgr_get_tape_by_size", 22);
EXEC SQL OPEN tape_size_cursor4upd;
if (sqlca.sqlcode) {
......@@ -795,19 +765,6 @@ int vmgr_get_side_by_size_byte_u64(struct vmgr_dbfd *dbfd,
:side_entry->vid, :side_entry->side, :side_entry->poolname,
:side_entry->status, :estimated_free_space_byte_str,
:side_entry->nbfiles;
/* If no data was found */
if (sqlca.sqlcode == 1403) {
EXEC SQL OPEN tape_maxsize_cursor4upd;
if (sqlca.sqlcode) {
vmgr_oracle_error (func, "OPEN CURSOR", dbfd, &sqlca);
return (-1);
}
EXEC SQL FETCH tape_maxsize_cursor4upd INTO
:rowid_value,
:side_entry->vid, :side_entry->side, :side_entry->poolname,
:side_entry->status, :estimated_free_space_byte_str,
:side_entry->nbfiles;
}
switch (sqlca.sqlcode) {
case 0:
if (lock)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment