mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 21:47:45 +00:00
STABLE14-salvage-zlc-update-20060905
deal with damaged namei volumes better (cherry picked from commit 2c103b8fb3a1b36e4c8eda986b8e82199d46e1b9)
This commit is contained in:
parent
ca56553044
commit
99629af9b7
@ -151,8 +151,7 @@ typedef struct {
|
||||
int ogm_mode;
|
||||
} namei_ogm_t;
|
||||
|
||||
int namei_SetLinkCount(FdHandle_t * h, Inode ino, int count, int locked);
|
||||
static int namei_GetLinkCount2(FdHandle_t * h, Inode ino, int lockit, int fixup);
|
||||
static int namei_GetLinkCount2(FdHandle_t * h, Inode ino, int lockit, int fixup, int nowrite);
|
||||
|
||||
static int GetFreeTag(IHandle_t * ih, int vno);
|
||||
|
||||
@ -863,13 +862,14 @@ namei_GetLCOffsetAndIndexFromIno(Inode ino, afs_foff_t * offset, int *index)
|
||||
* return.
|
||||
*/
|
||||
static int
|
||||
namei_GetLinkCount2(FdHandle_t * h, Inode ino, int lockit, int fixup)
|
||||
namei_GetLinkCount2(FdHandle_t * h, Inode ino, int lockit, int fixup, int nowrite)
|
||||
{
|
||||
unsigned short row = 0;
|
||||
afs_foff_t offset;
|
||||
ssize_t rc;
|
||||
int index;
|
||||
|
||||
if (!VALID_INO(ino)) return 0;
|
||||
/* there's no linktable yet. the salvager will create one later */
|
||||
if (h->fd_fd == -1 && fixup)
|
||||
return 1;
|
||||
@ -888,13 +888,14 @@ namei_GetLinkCount2(FdHandle_t * h, Inode ino, int lockit, int fixup)
|
||||
goto bad_getLinkByte;
|
||||
|
||||
rc = read(h->fd_fd, (char *)&row, sizeof(row));
|
||||
if ((rc == 0 || !((row >> index) & NAMEI_TAGMASK)) && fixup && nowrite)
|
||||
return 1;
|
||||
if (rc == 0 && fixup) {
|
||||
struct stat st;
|
||||
if (fstat(h->fd_fd, &st) || st.st_size >= offset+sizeof(row))
|
||||
goto bad_getLinkByte;
|
||||
FDH_TRUNC(h, offset+sizeof(row));
|
||||
row = 1 << index;
|
||||
rewrite:
|
||||
rc = write(h->fd_fd, (char *)&row, sizeof(row));
|
||||
}
|
||||
if (rc != sizeof(row)) {
|
||||
@ -903,7 +904,11 @@ rewrite:
|
||||
|
||||
if (fixup && !((row >> index) & NAMEI_TAGMASK)) {
|
||||
row |= 1<<index;
|
||||
goto rewrite;
|
||||
if (afs_lseek(h->fd_fd, offset, SEEK_SET) == -1)
|
||||
goto bad_getLinkByte;
|
||||
rc = write(h->fd_fd, (char *)&row, sizeof(row));
|
||||
if (rc != sizeof(row))
|
||||
goto bad_getLinkByte;
|
||||
}
|
||||
|
||||
return (int)((row >> index) & NAMEI_TAGMASK);
|
||||
@ -921,13 +926,7 @@ rewrite:
|
||||
int
|
||||
namei_GetLinkCount(FdHandle_t * h, Inode ino, int lockit)
|
||||
{
|
||||
return namei_GetLinkCount2(h, ino, lockit, 0);
|
||||
}
|
||||
|
||||
void
|
||||
namei_SetNonZLC(FdHandle_t * h, Inode ino)
|
||||
{
|
||||
(void)namei_GetLinkCount2(h, ino, 0, 1);
|
||||
return namei_GetLinkCount2(h, ino, lockit, 0, 1);
|
||||
}
|
||||
|
||||
/* Return a free column index for this vnode. */
|
||||
@ -1326,7 +1325,7 @@ namei_ListAFSSubDirs(IHandle_t * dirIH,
|
||||
dp1->d_name);
|
||||
linkHandle.fd_fd = afs_open(path2, Testing ? O_RDONLY : O_RDWR, 0666);
|
||||
info.linkCount =
|
||||
namei_GetLinkCount2(&linkHandle, (Inode) 0, 1, !Testing);
|
||||
namei_GetLinkCount2(&linkHandle, (Inode) 0, 1, 1, Testing);
|
||||
}
|
||||
if (judgeFun && !(*judgeFun) (&info, singleVolumeNumber, rock))
|
||||
continue;
|
||||
@ -1378,7 +1377,7 @@ namei_ListAFSSubDirs(IHandle_t * dirIH,
|
||||
continue;
|
||||
info.linkCount =
|
||||
namei_GetLinkCount2(&linkHandle,
|
||||
info.inodeNumber, 1, !Testing);
|
||||
info.inodeNumber, 1, 1, Testing);
|
||||
if (info.linkCount == 0) {
|
||||
#ifdef DELETE_ZLC
|
||||
Log("Found 0 link count file %s/%s, deleting it.\n", path3, dp3->d_name);
|
||||
|
@ -42,7 +42,7 @@ afs_sfsize_t namei_iwrite(IHandle_t * h, afs_foff_t offset, char *buf,
|
||||
extern int namei_dec(IHandle_t * h, Inode ino, int p1);
|
||||
extern int namei_inc(IHandle_t * h, Inode ino, int p1);
|
||||
extern int namei_GetLinkCount(FdHandle_t * h, Inode ino, int lockit);
|
||||
extern void namei_SetNonZLC(FdHandle_t * h, Inode ino);
|
||||
extern int namei_SetLinkCount(FdHandle_t * h, Inode ino, int count, int locked);
|
||||
extern int namei_ViceREADME(char *partition);
|
||||
#include "nfs.h"
|
||||
#include "viceinode.h"
|
||||
|
@ -1849,7 +1849,7 @@ CreateLinkTable(register struct InodeSummary *isp, Inode ino)
|
||||
Abort("Can't open link table for volume %u (error = %d)\n",
|
||||
isp->RWvolumeId, errno);
|
||||
|
||||
if (FDH_TRUNC(fdP, 0) < 0)
|
||||
if (FDH_TRUNC(fdP, sizeof(version) + sizeof(short)) < 0)
|
||||
Abort("Can't truncate link table for volume %u (error = %d)\n",
|
||||
isp->RWvolumeId, errno);
|
||||
|
||||
@ -1977,19 +1977,10 @@ DoSalvageVolumeGroup(register struct InodeSummary *isp, int nVols)
|
||||
fdP = IH_OPEN(VGLinkH);
|
||||
/* Sync fake 1 link counts to the link table, now that it exists */
|
||||
if (fdP) {
|
||||
#ifdef AFS_NT40_ENV
|
||||
nt_SetNonZLC(fdP, ino);
|
||||
#else
|
||||
namei_SetNonZLC(fdP, ino);
|
||||
#endif
|
||||
for (i = 0; i < nVols; i++) {
|
||||
ip = allInodes + isp[i].index;
|
||||
for (j = isp[i].nSpecialInodes; j < isp[i].nInodes; j++) {
|
||||
#ifdef AFS_NT40_ENV
|
||||
nt_SetNonZLC(fdP, ip[j].inodeNumber);
|
||||
#else
|
||||
namei_SetNonZLC(fdP, ip[j].inodeNumber);
|
||||
#endif
|
||||
namei_SetLinkCount(fdP, ip[j].inodeNumber, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user