libstorage-ng
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 
31 namespace 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 
91  bool has_referenced_limit() const;
92 
98  unsigned long long get_referenced_limit() const;
99 
103  void set_referenced_limit(unsigned long long referenced_limit);
104 
109 
113  bool has_exclusive_limit() const;
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  protected:
171 
172  BtrfsQgroup(Impl* impl);
173 
174  };
175 
176 
182  bool is_btrfs_qgroup(const Device* device);
183 
191 
195  const BtrfsQgroup* to_btrfs_qgroup(const Device* device);
196 
197 }
198 
199 #endif
storage::BtrfsQgroup
Class to represent a qgroup of a btrfs filesystem.
Definition: BtrfsQgroup.h:45
storage::BtrfsQgroup::get_id
id_t get_id() const
Get the id of the qgroup.
storage::BtrfsQgroup::get_referenced
unsigned long long get_referenced() const
Get the referenced size of the qgroup.
storage::BtrfsQgroup::get_referenced_limit
unsigned long long get_referenced_limit() const
Return the limit for the referenced size of the qgroup.
storage::BtrfsQgroup::get_exclusive
unsigned long long get_exclusive() const
Get the exclusive size of the qgroup.
storage::BtrfsQgroup::assign
void assign(BtrfsQgroup *btrfs_qgroup)
Assign btrfs_qgroup to the qgroup.
storage::BtrfsQgroup::id_t
std::pair< unsigned int, unsigned long long > id_t
Type for a btrfs qgroup id.
Definition: BtrfsQgroup.h:54
storage::BtrfsQgroup::set_exclusive_limit
void set_exclusive_limit(unsigned long long exclusive_limit)
Set the limit for the exclusive size of the qgroup.
storage
The storage namespace.
Definition: Actiongraph.h:39
storage::BtrfsQgroup::get_exclusive_limit
unsigned long long get_exclusive_limit() const
Return the limit for the exclusive size of the qgroup.
storage::BtrfsQgroup::clear_exclusive_limit
void clear_exclusive_limit()
Clear the limit for the exclusive size of the qgroup.
storage::BtrfsQgroup::clear_referenced_limit
void clear_referenced_limit()
Clear the limit for the referenced size of the qgroup.
storage::Devicegraph
The main container of the libstorage-ng.
Definition: Devicegraph.h:170
storage::BtrfsQgroup::is_assigned
bool is_assigned(const BtrfsQgroup *btrfs_qgroup) const
Return whether the btrfs_qgroup is assigned to the qgroup.
storage::Btrfs
Class to represent a btrfs filesystem https://en.wikipedia.org/wiki/Btrfs in the devicegraph.
Definition: Btrfs.h:80
storage::BtrfsQgroup::set_referenced_limit
void set_referenced_limit(unsigned long long referenced_limit)
Set the limit for the referenced size of the qgroup.
storage::is_btrfs_qgroup
bool is_btrfs_qgroup(const Device *device)
Checks whether device points to a Btrfs.
storage::BtrfsQgroup::has_referenced_limit
bool has_referenced_limit() const
Return whether the qgroup has a limit for the referenced size.
storage::Device
An abstract base class for storage devices.
Definition: Device.h:82
storage::BtrfsQgroup::unassign
void unassign(BtrfsQgroup *btrfs_qgroup)
Unassign btrfs_qgroup from the qgroup.
storage::BtrfsQgroup::get_assigned_btrfs_qgroups
std::vector< BtrfsQgroup * > get_assigned_btrfs_qgroups()
Get all qgroups assigned to the qgroup.
storage::BtrfsQgroup::create
static BtrfsQgroup * create(Devicegraph *devicegraph, const id_t &id)
storage::BtrfsQgroup::has_exclusive_limit
bool has_exclusive_limit() const
Return whether the qgroup has a limit for the exclusive size.
storage::BtrfsQgroup::get_assigned_btrfs_qgroups
std::vector< const BtrfsQgroup * > get_assigned_btrfs_qgroups() const
Get all qgroups assigned to the qgroup.
storage::to_btrfs_qgroup
BtrfsQgroup * to_btrfs_qgroup(Device *device)
Converts pointer to Device to pointer to Btrfs.
storage::BtrfsQgroup::get_btrfs
Btrfs * get_btrfs()
Get the btrfs filesystem this qgroup belongs to.
storage::BtrfsQgroup::get_btrfs
const Btrfs * get_btrfs() const
Get the btrfs filesystem this qgroup belongs to.