summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-inode-fd-ops.c
Commit message (Collapse)AuthorAgeFilesLines
* posix: Implement a janitor thread to close fdMohit Agrawal2020-08-201-15/+18
| | | | | | | | | | | | | | Problem: In the commit fb20713b380e1df8d7f9e9df96563be2f9144fd6 we use syntask to close fd but we have found the patch is reducing the performance Solution: Use janitor thread to close fd's and save the pfd ctx into ctx janitor list and also save the posix_xlator into pfd object to avoid the race condition during cleanup in brick_mux environment Change-Id: Ifb3d18a854b267333a3a9e39845bfefb83fbc092 Fixes: #1396 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
* dht - fixing xattr inconsistencyBarak Sason Rofman2020-07-221-0/+69
| | | | | | | | | | | | | | | | | The scenario of setting an xattr to a dir, killing one of the bricks, removing the xattr, bringing back the brick results in xattr inconsistency - The downed brick will still have the xattr, but the rest won't. This patch add a mechanism that will remove the extra xattrs during lookup. This patch is a modification to a previous patch based on comments that were made after merge: https://review.gluster.org/#/c/glusterfs/+/24613/ fixes: #1324 Change-Id: Ifec0b7aea6cd40daa8b0319b881191cf83e031d1 Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
* tests: skip tests on absence of reflink in xfsPranith Kumar K2020-05-061-2/+1
| | | | | | Fixes: #1223 Change-Id: I36cb72d920ffd77405051546615c5262c392daef Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
* Posix: Use simple approach to close fdMohit Agrawal2020-03-201-22/+6
| | | | | | | | | | | | | | | Problem: posix_release(dir) functions add the fd's into a ctx->janitor_fds and janitor thread closes the fd's.In brick_mux environment it is difficult to handle race condition in janitor threads because brick spawns a single janitor thread for all bricks. Solution: Use synctask to execute posix_release(dir) functions instead of using background a thread to close fds. Credits: Pranith Karampuri <pkarampu@redhat.com> Change-Id: Iffb031f0695a7da83d5a2f6bac8863dad225317e Fixes: bz#1811631 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
* xlators/storage: remove duplicated includesDmitry Antipov2020-01-131-1/+0
| | | | | | | | Do not include ftw.h twice. Change-Id: Id9e8d1813aafd890940adcd6883d90fa1b4beaf9 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Updates: bz#1193929
* posix-inode-fd-ops.c: fix a compiler warning - real_path may be NULLYaniv Kaul2020-01-011-1/+1
| | | | | | | | | | | | | | | | | | | | Fixes the following: posix-inode-fd-ops.c: In function ‘posix_common_removexattr’: ../../../../libglusterfs/src/glusterfs/logging.h:231:9: warning: ‘%s’ directive argument is null [-Wformat-overflow=] 231 | _gf_msg(dom, __FILE__, __FUNCTION__, __LINE__, level, errnum, 0, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 232 | msgid, ##fmt); \ | ~~~~~~~~~~~~~ posix-inode-fd-ops.c:4401:13: note: in expansion of macro ‘gf_msg’ 4401 | gf_msg(this->name, GF_LOG_WARNING, errno, P_MSG_FDSTAT_FAILED, | ^~~~~~ posix-inode-fd-ops.c:4402:47: note: format string is defined here 4402 | "fdstat operaton failed on %s", real_path); | ^~ Change-Id: I3f2278d3a05a569dde257d66f44a8655491b4013 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* posix: Avoid diskpace error in case of overwriting the dataMohit Agrawal2020-01-011-16/+125
| | | | | | | | | | | | | | Problem: Sometime fops like posix_writev, posix_fallocate, posix_zerofile failed and throw error ENOSPC if storage.reserve threshold limit has reached even fops is overwriting the data Solution: Retry the fops in case of overwrite if diskspace check is failed Credits: kinsu <vpolakis@gmail.com> Change-Id: I987d73bcf47ed1bb27878df40c39751296e95fe8 Updates: #745 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
* Avoid buffer overwrite due to uuid_utoa() misuseDmitry Antipov2019-12-271-2/+3
| | | | | | | | | | | | | | | Code like: f(..., uuid_utoa(x), uuid_utoa(y)); is not valid (causes undefined behaviour) because uuid_utoa() uses the only static thread-local buffer which will be overwritten by the subsequent call. All such cases should be converted to use uuid_utoa_r() with explicitly specified buffer. Change-Id: I5e72bab806d96a9dd1707c28ed69ca033b9c8d6c Updates: bz#1193929 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
* posix-inode-fd-ops.c: excute sys_fstat() only when neededYaniv Kaul2019-11-271-7/+16
| | | | | | | | | | | It appears that in posix_do_futimes() we may not need to unconditionally execute sys_fstat(). Avoid it and use the existing stbuf atime and mtime if possible. If not, we execute it. Change-Id: I0bdd471e5c821fcd28f057c75046c673a212d347 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* posix: Improve MAKE_HANDLE_PATHMohit Agrawal2019-11-181-19/+4
| | | | | | | | | Pass the maximum buffer (PATH_MAX) to posix_handle_path to avoid the posix_handle_path call again. Change-Id: I7d18313870218dc028c5f7fc94d6ec85a2bdb332 Updates #761 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
* Posix: UNUSED VALUE coverity fixPurna Pavan Chandra Aekkaladevi2019-10-111-2/+0
| | | | | | | | | | | | This patch fixes Coverity issue with CID 1274206 Problem : -1 is assigned to op_ret, but that stored value is overwritten before it can be used. Fix : Removal of the line that assigns -1 to op_ret which has no significance. Change-Id: Icb881549ac946003710551c9b9e88b33b6a06239 Updates: bz#789278 Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkala@redhat.com>
* ctime/rebalance: Heal ctime xattr on directory during rebalanceKotresh HR2019-09-161-34/+23
| | | | | | | | | | | | | | | | After add-brick and rebalance, the ctime xattr is not present on rebalanced directories on new brick. This patch fixes the same. Note that ctime still doesn't support consistent time across distribute sub-volume. This patch also fixes the in-memory inconsistency of time attributes when metadata is self healed. Change-Id: Ia20506f1839021bf61d4753191e7dc34b31bb2df fixes: bz#1734026 Signed-off-by: Kotresh HR <khiremat@redhat.com>
* posix*.c: remove unneeded strlen() callsYaniv Kaul2019-09-051-7/+4
| | | | | | | | | In various places, we can re-use knowledge of string length or result of snprintf() and such instead of strlen(). Change-Id: I4c9b1decf1169b3f8ac83699a0afbd7c38fad746 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* storage/posix - Fixing a coverity issueBarak Sason2019-08-211-0/+1
| | | | | | | | | | Fixed a resource leak of variable 'pfd' CID: 1400673 Updates: bz#789278 Change-Id: I78e1e8a89e0604b56e35a75c25d436b35db096c3 Signed-off-by: Barak Sason <bsasonro@redhat.com>
* storage/posix - fixing a coverity issueBarak Sason2019-08-211-2/+19
| | | | | | | | | | CID: 1394644 & 1394639 Updates: bz#789278 Added logging in case method calls fails Change-Id: Ib833a5f68d37b98287b84c325637bc688937f647 Signed-off-by: Barak Sason <bsasonro@redhat.com>
* ctime: Fix ctime issue with utime family of syscallsKotresh HR2019-08-201-4/+4
| | | | | | | | | When atime|mtime is updated via utime family of syscalls, ctime is not updated. This patch fixes the same. Change-Id: I7f86d8f8a1e06a332c3449b5bbdbf128c9690f25 fixes: bz#1738786 Signed-off-by: Kotresh HR <khiremat@redhat.com>
* ctime: Set mdata xattr on legacy filesKotresh HR2019-07-221-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The files which were created before ctime enabled would not have "trusted.glusterfs.mdata"(stores time attributes) xattr. Upon fops which modifies either ctime or mtime, the xattr gets created with latest ctime, mtime and atime, which is incorrect. It should update only the corresponding time attribute and rest from backend Solution: Creating xattr with values from brick is not possible as each brick of replica set would have different times. So create the xattr upon successful lookup if the xattr is not created Note To Reviewers: The time attributes used to set xattr is got from successful lookup. Instead of sending the whole iatt over the wire via setxattr, a structure called mdata_iatt is sent. The mdata_iatt contains only time attributes. Change-Id: I5e535631ddef04195361ae0364336410a2895dd4 fixes: bz#1593542 Signed-off-by: Kotresh HR <khiremat@redhat.com>
* posix : add posix_set_ctime() in posix_ftruncate()Jiffin Tony Thottan2019-06-271-0/+2
| | | | | | Change-Id: I0cb5320fea71306e0283509ae47024f23874b53b fixes: bz#1723761 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
* posix: modify storage.reserve option to take size and percentSheetal Pamecha2019-06-261-6/+9
| | | | | | | | | | | * reverting changes made in https://review.gluster.org/#/c/glusterfs/+/21686/ * Now storage.reserve can take value in percent or bytes fixes: bz#1651445 Change-Id: Id4826210ec27991c55b17d1fecd90356bff3e036 Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
* [RFC] change get_real_filename implementation to use ENOATTR instead of ENOENTMichael Adam2019-06-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | get_real_filename is implemented as a virtual extended attribute to help Samba implement the case-insensitive but case preserving SMB protocol more efficiently. It is implemented as a getxattr call on the parent directory with the virtual key of "get_real_filename:<entryname>" by looking for a spelling with different case for the provided file/dir name (<entryname>) and returning this correct spelling as a result if the entry is found. Originally (05aaec645a6262d431486eb5ac7cd702646cfcfb), the implementation used the ENOENT errno to return the authoritative answer that <entryname> does not exist in any case folding. Now this implementation is actually a violation or misuse of the defined API for the getxattr call which returns ENOENT for the case that the dir that the call is made against does not exist and ENOATTR (or the synonym ENODATA) for the case that the xattr does not exist. This was not a problem until the gluster fuse-bridge was changed to do map ENOENT to ESTALE in 59629f1da9dca670d5dcc6425f7f89b3e96b46bf, after which we the getxattr call for get_real_filename returned an ESTALE instead of ENOENT breaking the expectation in Samba. It is an independent problem that ESTALE should not leak out to user space but is intended to trigger retries between fuse and gluster. But nevertheless, the semantics seem to be incorrect here and should be changed. This patch changes the implementation of the get_real_filename virtual xattr to correctly return ENOATTR instead of ENOENT if the file/directory being looked up is not found. The Samba glusterfs_fuse vfs module which takes advantage of the get_real_filename over a fuse mount will receive a corresponding change to map ENOATTR to ENOENT. Without this change, it will still work correctly, but the performance optimization for nonexisting files is lost. On the other hand side, this change removes the distinction between the old not-implemented case and the implemented case. So Samba changed to treat ENOATTR like ENOENT will not work correctly any more against old servers that don't implement get_real_filename. I.e. existing files will be reported as non-existing Change-Id: I971b427ab8410636d5d201157d9af70e0d075b67 fixes: bz#1722977 Signed-off-by: Michael Adam <obnox@samba.org>
* posix: fix crash in posix_cs_set_stateSusant Palai2019-06-201-3/+4
| | | | | | Fixes: bz#1721474 Change-Id: Ic2a53fa3d1e9e23424c6898e0986f80d52c5e3f6 Signed-off-by: Susant Palai <spalai@redhat.com>
* multiple files: another attempt to remove includesYaniv Kaul2019-06-141-7/+1
| | | | | | | | | | | | | | | | | | There are many include statements that are not needed. A previous more ambitious attempt failed because of *BSD plafrom (see https://review.gluster.org/#/c/glusterfs/+/21929/ ) Now trying a more conservative reduction. It does not solve all circular deps that we have, but it does reduce some of them. There is just too much to handle reasonably (dht-common.h includes dht-lock.h which includes dht-common.h ...), but it does reduce the overall number of lines of include we need to look at in the future to understand and fix the mess later one. Change-Id: I550cd001bdefb8be0fe67632f783c0ef6bee3f9f updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* across: coverity fixesAmar Tumballi2019-06-031-0/+1
| | | | | | | | | | | | | | | * locks/posix.c: key was not freed in one of the cases. * locks/common.c: lock was being free'd out of context. * nfs/exports: handle case of missing free. * protocol/client: handle case of entry not freed. * storage/posix: handle possible case of double free CID: 1398628, 1400731, 1400732, 1400756, 1124796, 1325526 updates: bz#789278 Change-Id: Ieeaca890288bc4686355f6565f853dc8911344e8 Signed-off-by: Amar Tumballi <amarts@redhat.com> Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
* posix: add storage.reserve-size optionSheetal Pamecha2019-06-031-3/+7
| | | | | | | | | | | storage.reserve-size option will take size as input instead of percentage. If set, priority will be given to storage.reserve-size over storage.reserve. Default value of this option is 0. fixes: bz#1651445 Change-Id: I7a7342c68e436e8bf65bd39c567512ee04abbcea Signed-off-by: Sheetal Pamecha <sheetal.pamecha08@gmail.com>
* cloudsync: Make readdirp return stat info of all the direntsAnuradha Talur2019-04-251-0/+2
| | | | | | | | | | | | | | | This change got missed while the initial changes were sent. Should have been a part of : https://review.gluster.org/#/c/glusterfs/+/21757/ Gist of the change: Function that fills in stat info for dirents is invoked in readdirp in posix when cloudsync populates xdata request with GF_CS_OBJECT_STATUS. Change-Id: Ide0c4e80afb74cd2120f74ba934ed40123152d69 updates: bz#1642168 Signed-off-by: Anuradha Talur <atalur@commvault.com>
* storage/posix: changes with respect to cloudsyncAnuradha Talur2019-04-101-15/+124
| | | | | | | | | | Main changes include logic to update iatt buf with file size from extended attributes in posix rather than having this logic in cloudsync xlator. Change-Id: I44f5f8df7a01e496372557fe2f4eff368dbdaa33 fixes: bz#1642168 Signed-off-by: Anuradha Talur <atalur@commvault.com>
* storage/posix: Remove nr_files usagePranith Kumar K2019-03-141-2/+0
| | | | | | | | | | | | | | | | nr_files is supposed to represent the number of files opened in posix. Present logic doesn't seem to handle anon-fds because of which the counts would always be wrong. I don't remember anyone using this value in debugging any problem probably because we always have 'ls -l /proc/<pid>/fd' which not only prints the fds that are active but also prints their paths. It also handles directories and anon-fds which actually opened the file. So removing this code instead of fixing the buggy logic to have the nr_files. fixes bz#1688106 Change-Id: Ibf8713fdfdc1ef094e08e6818152637206a54040 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
* storage/posix: print the actual file pathRaghavendra Bhat2019-02-141-54/+75
| | | | | | | | | | | | | posix converts incoming operations on files to operations on corresponding gfid handles. While this in itself is not a problem, logging of those gfid handles in place of actual file paths can create confusions during debugging. The best way would be to print both the actual file (recieved as an argument) for path based operations and the gfid handle associated with it. Change-Id: I408c36ca6456f2e3981b93151c19ef7f60085ad6 fixes: bz#1675076 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
* afr/self-heal:Fix wrong type checkingRavishankar N2019-01-241-28/+1
| | | | | | | | | | gf_dirent struct has d_type variable which should check with DT_DIR istead of IA_IFDIR or IA_IFDIR has to compare with entry->d_stat.ia_type Change-Id: Idf1059ce2a590734bc5b6adaad73604d9a708804 updates: bz#1653359 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
* posix: Convert several posix_private members to gf_atomicMohit Agrawal2019-01-151-27/+5
| | | | | | Change-Id: I629698d8ddf6f15428880bdc1501d36bc37b8ebb fixes: bz#1657607 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
* posix: stack-buffer-overflow reported by asanHarpreet Kaur2018-12-261-1/+3
| | | | | | | | | | | | This patch fixes buffer overflow in $SRC/xlators/storage/posix/src/posix-inode-fd-ops.c Memory access at offset 432 overflows "md5_checksum" variable. SUMMARY: AddressSanitizer: stack-buffer-overflow (/lib64/libasan.so.5+0xb825a) updates: bz#1633930 Change-Id: I46010a09161d02cdf0c69679a334ec1d3d49cffb Signed-off-by: Harpreet Kaur <hlalwani@redhat.com>
* posix: use synctask for janitorPoornima G2018-12-191-16/+21
| | | | | | | | | | | | | | With brick mux, the number of threads increases as the number of bricks increases. As an initiative to reduce the number of threads in brick mux scenario, replacing janitor thread to use synctask infra. Now close() and closedir() handle by separate janitor thread which is linked with glusterfs_ctx. Updates #475 Change-Id: I0c4aaf728125ab7264442fde59f3d08542785f73 Signed-off-by: Poornima G <pgurusid@redhat.com>
* copy_file_range support in GlusterFSRaghavendra Bhat2018-12-121-0/+268
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libglusterfs changes to add new fop * Fuse changes: - Changes in fuse bridge xlator to receive and send responses * posix changes to perform the op on the backend filesystem * protocol and rpc changes for sending and receiving the fop * gfapi changes for performing the fop * tools: glfs-copy-file-range tool for testing copy_file_range fop - Although, copy_file_range support has been added to the upstream fuse kernel module, no release has been made yet of a kernel which contains the support. It is expected to come in the upcoming release of linux-4.20 So, as of now, executing copy_file_range fop on a fused based filesystem results in fuse kernel module sending read on the source fd and write on the destination fd. Therefore a small gfapi based tool has been written to be able test the copy_file_range fop. This tool is similar (in functionality) to the example program given in copy_file_range man page. So, running regular copy_file_range on a fuse mount point and running gfapi based glfs-copy-file-range tool gives some idea about how fast, the copy_file_range (or reflink) can be. On the local machine this was the result obtained. mount -t glusterfs workstation:new /mnt/glusterfs [root@workstation ~]# cd /mnt/glusterfs/ [root@workstation glusterfs]# ls file [root@workstation glusterfs]# cd [root@workstation ~]# time /tmp/a.out /mnt/glusterfs/file /mnt/glusterfs/new real 0m6.495s user 0m0.000s sys 0m1.439s [root@workstation ~]# time glfs-copy-file-range $(hostname) new /tmp/glfs.log /file /rrr OPEN_SRC: opening /file is success OPEN_DST: opening /rrr is success FSTAT_SRC: fstat on /rrr is success copy_file_range successful real 0m0.309s user 0m0.039s sys 0m0.017s This tool needs following arguments 1) hostname 2) volume name 3) log file path 4) source file path (relative to the gluster volume root) 5) destination file path (relative to the gluster volume root) "glfs-copy-file-range <hostname> <volume> <log file path> <source> <destination>" - Added a testcase as well to run glfs-copy-file-range tool * io-stats changes to capture the fop for profiling * NOTE: - Added conditional check to see whether the copy_file_range syscall is available or not. If not, then return ENOSYS. - Added conditional check for kernel minor version in fuse_kernel.h and fuse-bridge while referring to copy_file_range. And the kernel minor version is kept as it is. i.e. 24. Increment it in future when there is a kernel release which contains the support for copy_file_range fop in fuse kernel module. * The document which contains a writeup on this enhancement can be found at https://docs.google.com/document/d/1BSILbXr_knynNwxSyyu503JoTz5QFM_4suNIh2WwrSc/edit Change-Id: I280069c814dd21ce6ec3be00a884fc24ab692367 updates: #536 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
* libglusterfs: Move devel headers under glusterfs directoryShyamsundarR2018-12-051-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | libglusterfs devel package headers are referenced in code using include semantics for a program, this while it works can be better especially when dealing with out of tree xlator builds or in general out of tree devel package usage. Towards this, the following changes are done, - moved all devel headers under a glusterfs directory - Included these headers using system header notation <> in all code outside of libglusterfs - Included these headers using own program notation "" within libglusterfs This change although big, is just moving around the headers and making it correct when including these headers from other sources. This helps us correctly include libglusterfs includes without namespace conflicts. Change-Id: Id2a98854e671a7ee5d73be44da5ba1a74252423b Updates: bz#1193929 Signed-off-by: ShyamsundarR <srangana@redhat.com>
* posix: fix memory leakAmar Tumballi2018-11-281-7/+16
| | | | | | | | | | | | | | | | | | | | | | | Direct leak of 609960 byte(s) in 4485 object(s) allocated from: #0 0x7f0d719bea50 in __interceptor_calloc (/lib64/libasan.so.5+0xefa50) #1 0x7f0d716dc08f in __gf_calloc ../../../libglusterfs/src/mem-pool.c:111 #2 0x7f0d5d41d9b2 in __posix_get_mdata_xattr ../../../../../xlators/storage/posix/src/posix-metadata.c:240 #3 0x7f0d5d41dd6b in posix_get_mdata_xattr ../../../../../xlators/storage/posix/src/posix-metadata.c:317 #4 0x7f0d5d39e855 in posix_fdstat ../../../../../xlators/storage/posix/src/posix-helpers.c:685 #5 0x7f0d5d3d65ec in posix_create ../../../../../xlators/storage/posix/src/posix-entry-ops.c:2173 Direct leak of 609960 byte(s) in 4485 object(s) allocated from: #0 0x7f0d719bea50 in __interceptor_calloc (/lib64/libasan.so.5+0xefa50) #1 0x7f0d716dc08f in __gf_calloc ../../../libglusterfs/src/mem-pool.c:111 #2 0x7f0d5d41ced2 in posix_set_mdata_xattr ../../../../../xlators/storage/posix/src/posix-metadata.c:359 #3 0x7f0d5d41e70f in posix_set_ctime ../../../../../xlators/storage/posix/src/posix-metadata.c:616 #4 0x7f0d5d3d662c in posix_create ../../../../../xlators/storage/posix/src/posix-entry-ops.c:2181 We were freeing only the first context in inode during forget, and not the second. updates: bz#1633930 Change-Id: Ib61b4453aa3d2039d6ce660f52ef45390539b9db Signed-off-by: Amar Tumballi <amarts@redhat.com>
* posix: Fix null pointer dererfenceSusant Palai2018-11-141-0/+7
| | | | | | | | CID: 1124799 1214618 Change-Id: Iff05180983fe9600be0a2ce015a137e4efb8f533 updates: bz#789278 Signed-off-by: Susant Palai <spalai@redhat.com>
* posix: Fix coverity issueVarsha Rao2018-11-021-2/+6
| | | | | | | | | This patch fixes the unchecked return value, coverity issue. CID: 1391412 Change-Id: If85f4afdf8c6d37602c62fbf4d7c730e18be81e7 updates: bz#789278 Signed-off-by: Varsha Rao <varao@redhat.com>
* posix : fix coverity issues in posix-inode-fd-ops.cSunny Kumar2018-10-251-2/+2
| | | | | | | | This patch fixes CID: 1356526 and 1382369 : Argument cannot be negative Change-Id: I1aab5be2d217479db9f67a26b62854a0b38c1747 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* posix: fill glusterfs.posix.* acl xattrs at dictKinglong Mee2018-10-221-1/+1
| | | | | | Change-Id: I0730a037f96c4386c72ecf2f61c71ec17ffbc1b0 Updates: bz#1634220 Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
* posix: return more xattrs at getxattr/fgetxattr when client requestKinglong Mee2018-10-171-2/+26
| | | | | | Change-Id: I37ac6186b3631979d2503d1b185a61b8094dbd0d Updates: bz#1634220 Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
* all: fix warnings on non 64-bits architecturesXavi Hernandez2018-10-101-3/+3
| | | | | | | | | | When compiling in other architectures there appear many warnings. Some of them are actual problems that prevent gluster to work correctly on those architectures. Change-Id: Icdc7107a2bc2da662903c51910beddb84bdf03c0 fixes: bz#1632717 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
* storage/posix: Check if fd->inode is NULL before using itAshish Pandey2018-09-201-4/+4
| | | | | | | | | | | CID: 1395473, 1395472 https://scan6.coverity.com/reports.htm#v42607/p10714/fileInstanceId=85588219&defectInstanceId=26115956&mergedDefectId=1395472 https://scan6.coverity.com/reports.htm#v42607/p10714/fileInstanceId=85588219&defectInstanceId=26115961&mergedDefectId=1395473 Change-Id: I2c3cc350e0ac156616df6f568ba28dbfa68064bf updates: bz#789278 Signed-off-by: Ashish Pandey <aspandey@redhat.com>
* Land part 2 of clang-format changesGluster Ant2018-09-121-4287/+4288
| | | | | Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4 Signed-off-by: Nigel Babu <nigelb@redhat.com>
* posix: fix the duplicate macro definitionsAmar Tumballi2018-09-101-4/+0
| | | | | | | | | | the macro 'PATH_SET_TIMESPEC_OR_TIMEVAL' is defined in posix.h, which seems to be good place for it updates: bz#1193929 Change-Id: I521a2a6efeb26891c24637a5f06b1d90c00b1135 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* posix: disable open/read/write on special filesAmar Tumballi2018-09-061-0/+33
| | | | | | | | | | | | | | | | | | | In the file system, the responsibility w.r.to the block and char device files is related to only support for 'creating' them (using mknod(2)). Once the device files are created, the read/write syscalls for the specific devices are handled by the device driver registered for the specific major number, and depending on the minor number, it knows where to read from. Hence, we are at risk of reading contents from devices which are handled by the host kernel on server nodes. By disabling open/read/write on the device file, we would be safe with the bypass one can achieve from client side (using gfapi) Fixes: bz#1625096 Change-Id: I48c776b0af1cbd2a5240862826d3d8918601e47f Signed-off-by: Amar Tumballi <amarts@redhat.com>
* posix: remove not supported get/set contentAmar Tumballi2018-09-041-14/+0
| | | | | | | | | | | | | | getting and setting a file's content using extended attribute worked great as a GET/PUT alternative when an object storage is supported on top of Gluster. But it needs application changes, and also, it skips some caching layers. It is not used over years, and not supported any more. Remove the dead code. Fixes: bz#1625102 Change-Id: Ide3b3f1f644f6ca58558bbe45561f346f96b95b7 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* Multiple files: calloc -> mallocYaniv Kaul2018-09-041-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | xlators/storage/posix/src/posix-inode-fd-ops.c: xlators/storage/posix/src/posix-helpers.c: xlators/storage/bd/src/bd.c: xlators/protocol/client/src/client-lk.c: xlators/performance/quick-read/src/quick-read.c: xlators/performance/io-cache/src/page.c xlators/nfs/server/src/nfs3-helpers.c xlators/nfs/server/src/nfs-fops.c xlators/nfs/server/src/mount3udp_svc.c xlators/nfs/server/src/mount3.c xlators/mount/fuse/src/fuse-helpers.c xlators/mount/fuse/src/fuse-bridge.c xlators/mgmt/glusterd/src/glusterd-utils.c xlators/mgmt/glusterd/src/glusterd-syncop.h xlators/mgmt/glusterd/src/glusterd-snapshot.c xlators/mgmt/glusterd/src/glusterd-rpc-ops.c xlators/mgmt/glusterd/src/glusterd-replace-brick.c xlators/mgmt/glusterd/src/glusterd-op-sm.c xlators/mgmt/glusterd/src/glusterd-mgmt.c xlators/meta/src/subvolumes-dir.c xlators/meta/src/graph-dir.c xlators/features/trash/src/trash.c xlators/features/shard/src/shard.h xlators/features/shard/src/shard.c xlators/features/marker/src/marker-quota.c xlators/features/locks/src/common.c xlators/features/leases/src/leases-internal.c xlators/features/gfid-access/src/gfid-access.c xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.c xlators/features/bit-rot/src/bitd/bit-rot.c xlators/features/bit-rot/src/bitd/bit-rot-scrub.c bxlators/encryption/crypt/src/metadata.c xlators/encryption/crypt/src/crypt.c xlators/performance/md-cache/src/md-cache.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible It doesn't make sense to calloc (allocate and clear) memory when the code right away fills that memory with data. It may be optimized by the compiler, or have a microscopic performance improvement. In some cases, also changed allocation size to be sizeof some struct or type instead of a pointer - easier to read. In some cases, removed redundant strlen() calls by saving the result into a variable. 1. Only done for the straightforward cases. There's room for improvement. 2. Please review carefully, especially for string allocation, with the terminating NULL string. Only compile-tested! .. and allocate memory as much as needed. xlators/nfs/server/src/mount3.c : Don't blindly allocate PATH_MAX, but strlen() the string and allocate appropriately. Also, align error messges. updates: bz#1193929 Original-Author: Yaniv Kaul <ykaul@redhat.com> Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Ibda6f33dd180b7f7694f20a12af1e9576fe197f5
* multiple xlators (storage/posix): strncpy()->sprintf(), reduce strlen()'sYaniv Kaul2018-08-311-27/+29
| | | | | | | | | | | | | | | | | | | | | | | | xlators/storage/posix/src/posix-gfid-path.c xlators/storage/posix/src/posix-handle.c xlators/storage/posix/src/posix-helpers.c xlators/storage/posix/src/posix-inode-fd-ops.c xlators/storage/posix/src/posix.h strncpy may not be very efficient for short strings copied into a large buffer: If the length of src is less than n, strncpy() writes additional null bytes to dest to ensure that a total of n bytes are written. Instead, use snprintf(). Also: - save the result of strlen() and re-use it when possible. - move from strlen to SLEN (sizeof() ) for const strings. Compile-tested only! Change-Id: I056939f111a4ec6bc8ebd539ebcaf9eb67da6c95 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* clang-scan: fix multiple issuesAmar Tumballi2018-08-311-5/+12
| | | | | | | | | | | * Buffer overflow issue in glusterfsd * Null argument passed to function expecting non-null (event-epoll) * Make sure the op_ret value is set in macro (posix) Updates: bz#1622665 Change-Id: I32b378fc40a5e3ee800c0dfbc13335d44c9db9ac Signed-off-by: Amar Tumballi <amarts@redhat.com>
* multiple files: remove unndeeded memset()Yaniv Kaul2018-08-291-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a squash of multiple commits: contrib/fuse-lib/misc.c: remove unneeded memset() All flock variables are properly set, no need to memset it. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I8e0512c5a88daadb0e587f545fdb9b32ca8858a2 libglusterfs/src/{client_t|fd|inode|stack}.c: remove some memset() I don't think there's a need for any of them. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I2be9ccc3a5cb5da51a92af73488cdabd1c527f59 libglusterfs/src/xlator.c: remove unneeded memset() All xl->mem_acct members are properly set, no need to memset it. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I7f264cd47e7a06255a3f3943c583de77ae8e3147 xlators/cluster/afr/src/afr-self-heal-common.c: remove unneeded memset() Since we are going over the whole array anyway, initialize it properly, to either 1 or 0. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Ied4210388976b6a7a2e91cc3de334534d6fef201 xlators/cluster/dht/src/dht-common.c: remove unneeded memset() Since we are going over the whole array anyway it is initialized properly. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Idc436d2bd0563b6582908d7cbebf9dbc66a42c9a xlators/cluster/ec/src/ec-helpers.c: remove unneeded memset() Since we are going over the whole array anyway it is initialized properly. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I81bf971f7fcecb4599e807d37f426f55711978fa xlators/mgmt/glusterd/src/glusterd-volgen.c: remove some memset() I don't think there's a need for any of them. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I476ea59ba53546b5153c269692cd5383da81ce2d xlators/mgmt/glusterd/src/glusterd-geo-rep.c: read() in 4K blocks The current 1K seems small. 4K is usually better (in Linux). Also remove a memset() that I don't think is needed between reads. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I5fb7950c92d282948376db14919ad12e589eac2b xlators/storage/posix/src/posix-{gfid-path|inode-fd-ops}.c: remove memset() before sys_*xattr() functions. I don't see a reason to memset the array sent to the functions sys_llistxattr(), sys_lgetxattr(), sys_lgetxattr(), sys_flistxattr(), sys_fgetxattr(). (Note: it's unclear to me why we are calling sys_*txattr() functions with XATTR_VAL_BUF_SIZE-1 size instead of XATTR_VAL_BUF_SIZE ). Only compile-tested! Change-Id: Ief2103b56ba6c71e40ed343a93684eef6b771346 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>