Patent ID: 7805471

Claim:
A computer implemented method for truncating a file in a file system, the method comprising: receiving a request to truncate the file to a target size, the file having a primary inode; creating a transient directory inode, wherein the transient directory inode holds a plurality of in-progress entries; setting a target size in the primary inode; writing a truncate entry to a journal, the truncate entry comprising a predetermined size; truncating the file by up to the predetermined size; determining that the file is above the target size; responsive to a determination that the file is above the target size, repeating the truncating step and the determining step; responsive to a determination that the file is not above the target size, apply the in-progress entries from the transient directory inode; determining whether a used buffer count is equal to a maximum buffer count; responsive to a determination that the used buffer count is not equal to the maximum buffer count, obtaining a lock to at least one entity; responsive to a determination that the used buffer count is equal to the maximum buffer count, increasing the used buffer count; responsive to a determination that the used buffer count is equal to the maximum buffer count, performing the receiving, creating, setting, writing, determining, repeating, and removing steps; releasing the lock; and decreasing the used buffer count of a buffer cache, whereby the buffer cache is not exhausted.