No longer tries to update indices from deleted files. Added new method
Inode::IsDeleted(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10879 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/* Inode - inode access functions
|
/* Inode - inode access functions
|
||||||
*
|
*
|
||||||
* Copyright 2001-2004, Axel Dörfler, [email protected].
|
* Copyright 2001-2005, Axel Dörfler, [email protected].
|
||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -1840,7 +1840,8 @@ Inode::NeedsTrimming()
|
|||||||
{
|
{
|
||||||
// We never trim preallocated index blocks to make them grow as smooth as possible.
|
// We never trim preallocated index blocks to make them grow as smooth as possible.
|
||||||
// There are only few indices anyway, so this doesn't hurt
|
// There are only few indices anyway, so this doesn't hurt
|
||||||
if (IsIndex())
|
// Also, if an inode is already in deleted state, we don't bother trimming it
|
||||||
|
if (IsIndex() || IsDeleted())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
off_t roundedSize = (Size() + fVolume->BlockSize() - 1) & ~(fVolume->BlockSize() - 1);
|
off_t roundedSize = (Size() + fVolume->BlockSize() - 1) & ~(fVolume->BlockSize() - 1);
|
||||||
@@ -2054,7 +2055,7 @@ Inode::Remove(Transaction &transaction, const char *name, off_t *_id, bool isDir
|
|||||||
// Deleted inodes won't be visible in queries anyway.
|
// Deleted inodes won't be visible in queries anyway.
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((inode->Mode() & (S_FILE | S_SYMLINK)) != 0) {
|
if (inode->IsFile() || inode->IsSymLink()) {
|
||||||
if (inode->IsFile())
|
if (inode->IsFile())
|
||||||
index.RemoveSize(transaction, inode);
|
index.RemoveSize(transaction, inode);
|
||||||
index.RemoveLastModified(transaction, inode);
|
index.RemoveLastModified(transaction, inode);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Inode - inode access functions
|
/* Inode - inode access functions
|
||||||
*
|
*
|
||||||
* Copyright 2001-2004, Axel Dörfler, axeld@pinc-software.de.
|
* Copyright 2001-2005, Axel Dörfler, axeld@pinc-software.de.
|
||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef INODE_H
|
#ifndef INODE_H
|
||||||
@@ -75,6 +75,8 @@ class Inode {
|
|||||||
bool HasUserAccessableStream() const { return S_ISREG(Mode()); }
|
bool HasUserAccessableStream() const { return S_ISREG(Mode()); }
|
||||||
// currently only files can be accessed with bfs_read()/bfs_write()
|
// currently only files can be accessed with bfs_read()/bfs_write()
|
||||||
|
|
||||||
|
bool IsDeleted() const { return (Flags() & INODE_DELETED) != 0; }
|
||||||
|
|
||||||
mode_t Mode() const { return fNode.Mode(); }
|
mode_t Mode() const { return fNode.Mode(); }
|
||||||
uint32 Type() const { return fNode.Type(); }
|
uint32 Type() const { return fNode.Type(); }
|
||||||
int32 Flags() const { return fNode.Flags(); }
|
int32 Flags() const { return fNode.Flags(); }
|
||||||
|
|||||||
@@ -698,11 +698,13 @@ bfs_write_stat(void *_ns, void *_node, const struct stat *stat, uint32 mask)
|
|||||||
// fill the new blocks (if any) with zeros
|
// fill the new blocks (if any) with zeros
|
||||||
inode->FillGapWithZeros(inode->OldSize(), inode->Size());
|
inode->FillGapWithZeros(inode->OldSize(), inode->Size());
|
||||||
|
|
||||||
Index index(volume);
|
if (!inode->IsDeleted()) {
|
||||||
index.UpdateSize(transaction, inode);
|
Index index(volume);
|
||||||
|
index.UpdateSize(transaction, inode);
|
||||||
|
|
||||||
if ((mask & FS_WRITE_STAT_MTIME) == 0)
|
if ((mask & FS_WRITE_STAT_MTIME) == 0)
|
||||||
index.UpdateLastModified(transaction, inode);
|
index.UpdateLastModified(transaction, inode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,10 +719,12 @@ bfs_write_stat(void *_ns, void *_node, const struct stat *stat, uint32 mask)
|
|||||||
node.gid = HOST_ENDIAN_TO_BFS_INT32(stat->st_gid);
|
node.gid = HOST_ENDIAN_TO_BFS_INT32(stat->st_gid);
|
||||||
|
|
||||||
if (mask & FS_WRITE_STAT_MTIME) {
|
if (mask & FS_WRITE_STAT_MTIME) {
|
||||||
// Index::UpdateLastModified() will set the new time in the inode
|
if (!inode->IsDeleted()) {
|
||||||
Index index(volume);
|
// Index::UpdateLastModified() will set the new time in the inode
|
||||||
index.UpdateLastModified(transaction, inode,
|
Index index(volume);
|
||||||
(bigtime_t)stat->st_mtime << INODE_TIME_SHIFT);
|
index.UpdateLastModified(transaction, inode,
|
||||||
|
(bigtime_t)stat->st_mtime << INODE_TIME_SHIFT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mask & FS_WRITE_STAT_CRTIME) {
|
if (mask & FS_WRITE_STAT_CRTIME) {
|
||||||
node.create_time = HOST_ENDIAN_TO_BFS_INT64((bigtime_t)stat->st_crtime << INODE_TIME_SHIFT);
|
node.create_time = HOST_ENDIAN_TO_BFS_INT64((bigtime_t)stat->st_crtime << INODE_TIME_SHIFT);
|
||||||
@@ -1182,7 +1186,7 @@ bfs_write(void *_ns, void *_node, void *_cookie, off_t pos, const void *buffer,
|
|||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
// periodically notify if the file size has changed
|
// periodically notify if the file size has changed
|
||||||
// ToDo: should we better test for a change in the last_modified time only?
|
// ToDo: should we better test for a change in the last_modified time only?
|
||||||
if (cookie->last_size != inode->Size()
|
if (!inode->IsDeleted() && cookie->last_size != inode->Size()
|
||||||
&& system_time() > cookie->last_notification + INODE_NOTIFICATION_INTERVAL) {
|
&& system_time() > cookie->last_notification + INODE_NOTIFICATION_INTERVAL) {
|
||||||
notify_listener(B_STAT_CHANGED, volume->ID(), 0, 0, inode->ID(), NULL);
|
notify_listener(B_STAT_CHANGED, volume->ID(), 0, 0, inode->ID(), NULL);
|
||||||
cookie->last_size = inode->Size();
|
cookie->last_size = inode->Size();
|
||||||
@@ -1224,8 +1228,11 @@ bfs_free_cookie(void *_ns, void *_node, void *_cookie)
|
|||||||
|
|
||||||
bool needsTrimming = inode->NeedsTrimming();
|
bool needsTrimming = inode->NeedsTrimming();
|
||||||
|
|
||||||
if (cookie->open_mode & O_RWMASK
|
if ((cookie->open_mode & O_RWMASK) != 0
|
||||||
&& (needsTrimming || inode->OldLastModified() != inode->LastModified())) {
|
&& !inode->IsDeleted()
|
||||||
|
&& (needsTrimming
|
||||||
|
|| inode->OldLastModified() != inode->LastModified()
|
||||||
|
|| inode->OldSize() != inode->Size())) {
|
||||||
#ifdef UNSAFE_GET_VNODE
|
#ifdef UNSAFE_GET_VNODE
|
||||||
RecursiveLocker locker(volume->Lock());
|
RecursiveLocker locker(volume->Lock());
|
||||||
#endif
|
#endif
|
||||||
@@ -1243,7 +1250,8 @@ bfs_free_cookie(void *_ns, void *_node, void *_cookie)
|
|||||||
status = inode->TrimPreallocation(transaction);
|
status = inode->TrimPreallocation(transaction);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
FATAL(("Could not trim preallocated blocks!"));
|
FATAL(("Could not trim preallocated blocks!"));
|
||||||
|
}
|
||||||
|
if (needsTrimming || inode->OldSize() != inode->Size()) {
|
||||||
index.UpdateSize(transaction, inode);
|
index.UpdateSize(transaction, inode);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user