fsck: rename "CorruptItems" channel to "MitigatedCorruptions"
Make it clear that this channel is only used to report corruptions that are transparently mitigated and do not return an error to the user.
This commit is contained in:
parent
283184dd5a
commit
1a18d8e609
8
fsck.go
8
fsck.go
@ -38,7 +38,7 @@ func (ck *fsckObj) dir(path string) {
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case item := <-ck.fs.CorruptItems:
|
case item := <-ck.fs.MitigatedCorruptions:
|
||||||
fmt.Printf("fsck: corrupt entry in dir %q: %q\n", path, item)
|
fmt.Printf("fsck: corrupt entry in dir %q: %q\n", path, item)
|
||||||
ck.markCorrupt(filepath.Join(path, item))
|
ck.markCorrupt(filepath.Join(path, item))
|
||||||
case <-done:
|
case <-done:
|
||||||
@ -102,7 +102,7 @@ func (ck *fsckObj) file(path string) {
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case item := <-ck.fs.CorruptItems:
|
case item := <-ck.fs.MitigatedCorruptions:
|
||||||
fmt.Printf("fsck: corrupt file %q (inode %s)\n", path, item)
|
fmt.Printf("fsck: corrupt file %q (inode %s)\n", path, item)
|
||||||
ck.markCorrupt(path)
|
ck.markCorrupt(path)
|
||||||
case <-done:
|
case <-done:
|
||||||
@ -132,7 +132,7 @@ func (ck *fsckObj) xattrs(path string) {
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case item := <-ck.fs.CorruptItems:
|
case item := <-ck.fs.MitigatedCorruptions:
|
||||||
fmt.Printf("fsck: corrupt xattr name on file %q: %q\n", path, item)
|
fmt.Printf("fsck: corrupt xattr name on file %q: %q\n", path, item)
|
||||||
ck.markCorrupt(path + " xattr:" + item)
|
ck.markCorrupt(path + " xattr:" + item)
|
||||||
case <-done:
|
case <-done:
|
||||||
@ -164,7 +164,7 @@ func fsck(args *argContainer) {
|
|||||||
args.allow_other = false
|
args.allow_other = false
|
||||||
pfs, wipeKeys := initFuseFrontend(args)
|
pfs, wipeKeys := initFuseFrontend(args)
|
||||||
fs := pfs.(*fusefrontend.FS)
|
fs := pfs.(*fusefrontend.FS)
|
||||||
fs.CorruptItems = make(chan string)
|
fs.MitigatedCorruptions = make(chan string)
|
||||||
ck := fsckObj{
|
ck := fsckObj{
|
||||||
fs: fs,
|
fs: fs,
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func (f *file) readFileID() ([]byte, error) {
|
|||||||
if err == io.EOF && n != 0 {
|
if err == io.EOF && n != 0 {
|
||||||
tlog.Warn.Printf("readFileID %d: incomplete file, got %d instead of %d bytes",
|
tlog.Warn.Printf("readFileID %d: incomplete file, got %d instead of %d bytes",
|
||||||
f.qIno.Ino, n, readLen)
|
f.qIno.Ino, n, readLen)
|
||||||
f.fs.reportCorruptItem(fmt.Sprint(f.qIno.Ino))
|
f.fs.reportMitigatedCorruption(fmt.Sprint(f.qIno.Ino))
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,15 @@ type FS struct {
|
|||||||
// This lock is used by openWriteOnlyFile() to block concurrent opens while
|
// This lock is used by openWriteOnlyFile() to block concurrent opens while
|
||||||
// it relaxes the permissions on a file.
|
// it relaxes the permissions on a file.
|
||||||
openWriteOnlyLock sync.RWMutex
|
openWriteOnlyLock sync.RWMutex
|
||||||
// CorruptItems is filled with file or xattr names that have been
|
// MitigatedCorruptions is used to report data corruption that is internally
|
||||||
// skipped (ignored) because they were corrupt. This is used by fsck
|
// mitigated by ignoring the corrupt item. For example, when OpenDir() finds
|
||||||
// to inform the user.
|
// a corrupt filename, we still return the other valid filenames.
|
||||||
// Use the reportCorruptItem() function to push an item.
|
// The corruption is logged to syslog to inform the user, and in addition,
|
||||||
CorruptItems chan string
|
// the corrupt filename is logged to this channel via
|
||||||
|
// reportMitigatedCorruption().
|
||||||
|
// "gocryptfs -fsck" reads from the channel to also catch these transparently-
|
||||||
|
// mitigated corruptions.
|
||||||
|
MitigatedCorruptions chan string
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ pathfs.FileSystem = &FS{} // Verify that interface is implemented.
|
var _ pathfs.FileSystem = &FS{} // Verify that interface is implemented.
|
||||||
@ -607,12 +611,16 @@ func (fs *FS) Access(path string, mode uint32, context *fuse.Context) (code fuse
|
|||||||
return fuse.ToStatus(syscall.Access(cPath, mode))
|
return fuse.ToStatus(syscall.Access(cPath, mode))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FS) reportCorruptItem(item string) {
|
// reportMitigatedCorruption is used to report a corruption that was transparently
|
||||||
if fs.CorruptItems == nil {
|
// mitigated and did not return an error to the user. Pass the name of the corrupt
|
||||||
|
// item (filename for OpenDir(), xattr name for ListXAttr() etc).
|
||||||
|
// See the MitigatedCorruptions channel for more info.
|
||||||
|
func (fs *FS) reportMitigatedCorruption(item string) {
|
||||||
|
if fs.MitigatedCorruptions == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case fs.CorruptItems <- item:
|
case fs.MitigatedCorruptions <- item:
|
||||||
case <-time.After(1 * time.Second):
|
case <-time.After(1 * time.Second):
|
||||||
tlog.Warn.Printf("BUG: reportCorruptItem: timeout")
|
tlog.Warn.Printf("BUG: reportCorruptItem: timeout")
|
||||||
//debug.PrintStack()
|
//debug.PrintStack()
|
||||||
|
@ -326,7 +326,7 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Warn.Printf("OpenDir %q: invalid entry %q: Could not read .name: %v",
|
tlog.Warn.Printf("OpenDir %q: invalid entry %q: Could not read .name: %v",
|
||||||
cDirName, cName, err)
|
cDirName, cName, err)
|
||||||
fs.reportCorruptItem(cName)
|
fs.reportMitigatedCorruption(cName)
|
||||||
errorCount++
|
errorCount++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Warn.Printf("OpenDir %q: invalid entry %q: %v",
|
tlog.Warn.Printf("OpenDir %q: invalid entry %q: %v",
|
||||||
cDirName, cName, err)
|
cDirName, cName, err)
|
||||||
fs.reportCorruptItem(cName)
|
fs.reportMitigatedCorruption(cName)
|
||||||
if runtime.GOOS == "darwin" && cName == dsStoreName {
|
if runtime.GOOS == "darwin" && cName == dsStoreName {
|
||||||
// MacOS creates lots of these files. Log the warning but don't
|
// MacOS creates lots of these files. Log the warning but don't
|
||||||
// increment errorCount - does not warrant returning EIO.
|
// increment errorCount - does not warrant returning EIO.
|
||||||
|
@ -106,7 +106,7 @@ func (fs *FS) ListXAttr(path string, context *fuse.Context) ([]string, fuse.Stat
|
|||||||
name, err := fs.decryptXattrName(curName)
|
name, err := fs.decryptXattrName(curName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Warn.Printf("ListXAttr: invalid xattr name %q: %v", curName, err)
|
tlog.Warn.Printf("ListXAttr: invalid xattr name %q: %v", curName, err)
|
||||||
fs.reportCorruptItem(curName)
|
fs.reportMitigatedCorruption(curName)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
names = append(names, name)
|
names = append(names, name)
|
||||||
|
Loading…
Reference in New Issue
Block a user