libstorage-ng
 
Loading...
Searching...
No Matches
BtrfsQgroup.h
1/*
2 * Copyright (c) 2020 SUSE LLC
3 *
4 * All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as published
8 * by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, contact Novell, Inc.
17 *
18 * To contact Novell about this file by physical or electronic mail, you may
19 * find current contact information at www.novell.com.
20 */
21
22
23#ifndef STORAGE_BTRFS_QGROUP_H
24#define STORAGE_BTRFS_QGROUP_H
25
26
27#include "storage/Devicegraph.h"
28#include "storage/Devices/Device.h"
29
30
31namespace storage
32{
33
34 class Btrfs;
35
36
44 class BtrfsQgroup : public Device
45 {
46 public:
47
54 using id_t = std::pair<unsigned int, unsigned long long>;
55
59 static BtrfsQgroup* create(Devicegraph* devicegraph, const id_t& id);
60
61 static BtrfsQgroup* load(Devicegraph* devicegraph, const xmlNode* node);
62
67
71 const Btrfs* get_btrfs() const;
72
76 id_t get_id() const;
77
81 unsigned long long get_referenced() const;
82
86 unsigned long long get_exclusive() const;
87
92
98 unsigned long long get_referenced_limit() const;
99
103 void set_referenced_limit(unsigned long long referenced_limit);
104
109
114
120 unsigned long long get_exclusive_limit() const;
121
125 void set_exclusive_limit(unsigned long long exclusive_limit);
126
131
135 bool is_assigned(const BtrfsQgroup* btrfs_qgroup) const;
136
142 void assign(BtrfsQgroup* btrfs_qgroup);
143
149 void unassign(BtrfsQgroup* btrfs_qgroup);
150
154 std::vector<BtrfsQgroup*> get_assigned_btrfs_qgroups();
155
159 std::vector<const BtrfsQgroup*> get_assigned_btrfs_qgroups() const;
160
161 public:
162
163 class Impl;
164
165 Impl& get_impl();
166 const Impl& get_impl() const;
167
168 virtual BtrfsQgroup* clone() const override;
169
170 BtrfsQgroup(Impl* impl);
171
172 };
173
174
180 bool is_btrfs_qgroup(const Device* device);
181
189
193 const BtrfsQgroup* to_btrfs_qgroup(const Device* device);
194
195}
196
197#endif
Class to represent a qgroup of a btrfs filesystem.
Definition BtrfsQgroup.h:45
void assign(BtrfsQgroup *btrfs_qgroup)
Assign btrfs_qgroup to the qgroup.
unsigned long long get_referenced_limit() const
Return the limit for the referenced size of the qgroup.
void set_referenced_limit(unsigned long long referenced_limit)
Set the limit for the referenced size of the qgroup.
std::pair< unsigned int, unsigned long long > id_t
Type for a btrfs qgroup id.
Definition BtrfsQgroup.h:54
unsigned long long get_referenced() const
Get the referenced size of the qgroup.
void clear_referenced_limit()
Clear the limit for the referenced size of the qgroup.
void set_exclusive_limit(unsigned long long exclusive_limit)
Set the limit for the exclusive size of the qgroup.
bool has_referenced_limit() const
Return whether the qgroup has a limit for the referenced size.
std::vector< const BtrfsQgroup * > get_assigned_btrfs_qgroups() const
Get all qgroups assigned to the qgroup.
const Btrfs * get_btrfs() const
Get the btrfs filesystem this qgroup belongs to.
Btrfs * get_btrfs()
Get the btrfs filesystem this qgroup belongs to.
static BtrfsQgroup * create(Devicegraph *devicegraph, const id_t &id)
std::vector< BtrfsQgroup * > get_assigned_btrfs_qgroups()
Get all qgroups assigned to the qgroup.
unsigned long long get_exclusive_limit() const
Return the limit for the exclusive size of the qgroup.
bool has_exclusive_limit() const
Return whether the qgroup has a limit for the exclusive size.
void clear_exclusive_limit()
Clear the limit for the exclusive size of the qgroup.
bool is_assigned(const BtrfsQgroup *btrfs_qgroup) const
Return whether the btrfs_qgroup is assigned to the qgroup.
unsigned long long get_exclusive() const
Get the exclusive size of the qgroup.
id_t get_id() const
Get the id of the qgroup.
void unassign(BtrfsQgroup *btrfs_qgroup)
Unassign btrfs_qgroup from the qgroup.
Class to represent a btrfs filesystem https://en.wikipedia.org/wiki/Btrfs in the devicegraph.
Definition Btrfs.h:80
An abstract base class for storage devices.
Definition Device.h:82
The main container of the libstorage-ng.
Definition Devicegraph.h:170
The storage namespace.
Definition Actiongraph.h:40
bool is_btrfs_qgroup(const Device *device)
Checks whether device points to a Btrfs.
BtrfsQgroup * to_btrfs_qgroup(Device *device)
Converts pointer to Device to pointer to Btrfs.