Skip to content

Commit

Permalink
DevCachefiles: remove unused method IsInUse()
Browse files Browse the repository at this point in the history
Since "cull" has the same checks, I don't think we'll ever need the
"inuse" command.
  • Loading branch information
MaxKellermann committed Dec 5, 2024
1 parent b7ab4d9 commit 3275f62
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
33 changes: 0 additions & 33 deletions src/DevCachefiles.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,6 @@

#include <limits.h> // for NAME_MAX

#if 0
// TODO does this now work because of the cachefiles CWD problem
[[gnu::pure]]
static Co::Task<bool>
IsInUse(Uring::Queue &uring, FileDescriptor dev_cachefiles, std::string_view filename)
try {
if (filename.size() >= NAME_MAX)
co_return false;

// unfortunately, fscache is buggy with writev()
const auto buffer = FmtBuffer<NAME_MAX + 8>("inuse {}", filename);

co_await Uring::CoWrite(uring, dev_cachefiles,
AsBytes(std::string_view{buffer}), 0);
co_return false;
} catch (const std::system_error &e) {
co_return IsErrno(e, EBUSY);
}
#endif

bool
DevCachefiles::IsInUse(std::string_view filename) noexcept
{
if (filename.size() >= NAME_MAX)
return false;

// unfortunately, fscache is buggy with writev()
const auto buffer = FmtBuffer<NAME_MAX + 8>("inuse {}", filename);

return fd.Write(AsBytes(std::string_view{buffer})) < 0 &&
errno == EBUSY;
}

DevCachefiles::CullResult
DevCachefiles::CullFile(std::string_view filename) noexcept
{
Expand Down
3 changes: 0 additions & 3 deletions src/DevCachefiles.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ public:
DevCachefiles(const DevCachefiles &) = delete;
DevCachefiles &operator=(const DevCachefiles &) = delete;

[[gnu::pure]]
bool IsInUse(std::string_view filename) noexcept;

enum class CullResult {
SUCCESS,
BUSY,
Expand Down

0 comments on commit 3275f62

Please sign in to comment.